-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: customize gradio components with lightning colors #17054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Borda
merged 69 commits into
Lightning-AI:master
from
KogaiIrina:feature/customized-gradio-components
Apr 24, 2023
Merged
Changes from 16 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
4ae6893
feat: customize gradio components with lightning colors
KogaiIrina 4311beb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 44fc012
Merge branch 'Lightning-AI:master' into feature/customized-gradio-com…
KogaiIrina c22dda4
move demo app from test to examples, add css file
KogaiIrina 60c1314
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b05d3ad
add option to customize the gradio components, add readme with example
KogaiIrina a7931b2
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina 1291321
add example with path to css file
KogaiIrina a53ff4b
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina c102a49
fix tests
KogaiIrina d92c5c6
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina fe40554
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina 5490689
Apply suggestions from code review
Borda 22f07cc
Merge branch 'master' into feature/customized-gradio-components
Borda 32a8019
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina 07e6b4c
rename variable
KogaiIrina 1a0b38a
Apply suggestions from code review
Borda b689872
Merge branch 'master' into feature/customized-gradio-components
Borda ff6e825
Merge branch 'master' into feature/customized-gradio-components
yurijmikhalevich 3e0d1d7
Merge branch 'master' into feature/customized-gradio-components
yurijmikhalevich 12e7556
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4fa244e
bump ci
KogaiIrina 2c470a1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c58fd6a
Merge branch 'master' into feature/customized-gradio-components
yurijmikhalevich 321a946
Merge branch 'master' into feature/customized-gradio-components
Borda f40349e
Merge branch 'master' into feature/customized-gradio-components
yurijmikhalevich 3337129
Merge branch 'master' into feature/customized-gradio-components
yurijmikhalevich 52f33ff
Merge branch 'master' into feature/customized-gradio-components
Borda d7b6c85
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina b4500cb
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina 844e553
create "native" Gradio theme
KogaiIrina 424f3c7
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina 48a44c1
remove commented code
KogaiIrina ca9b9ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0813803
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina 22beaa4
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina 862209f
import gradio
KogaiIrina f3882c4
put gradio directory back
KogaiIrina 8167eae
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina a76959a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2cf0a31
remove elon img
KogaiIrina c159410
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina d8c4804
put comments back
KogaiIrina 027f5c0
put copyright comments into gradio_server.py
KogaiIrina 91eba51
remove tabs
KogaiIrina 173a788
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 08ef3bd
remove unused import
KogaiIrina 6e8fe41
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina 4707ec7
mock gradio colors and default
KogaiIrina c21ca38
Merge branch 'master' into feature/customized-gradio-components
KogaiIrina 9aeacad
add DummyColor class for tests
KogaiIrina e45fc1c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 274b85e
make DummyDefault for test
KogaiIrina 9f51c9e
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina 62f5878
remove version.info
KogaiIrina 2e23728
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4e818be
Merge branch 'feature/customized-gradio-components' of github.com:Kog…
KogaiIrina c9be8f6
fix tests
KogaiIrina aad346d
put version info back
KogaiIrina 939932b
replace link for upload elon image in examples, move theme into serve…
KogaiIrina 95abccc
fix test
KogaiIrina b52e9fb
replace BAse with Theme
KogaiIrina 71c1fa6
attempt
KogaiIrina 0478add
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 71364c3
attempt at making CI happy
KogaiIrina ca197df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d52720a
fix test
KogaiIrina fe22aa9
Merge branch 'master' into feature/customized-gradio-components
Borda 6aa9fa7
chlog
awaelchli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Customize Gradio components | ||
|
||
If you want to customize gradio component by yourself, you need to pass `css` argument to ServeGradio like this: | ||
|
||
```py | ||
class AnimeGANv2UI(ServeGradio): | ||
inputs = gr.inputs.Image(type="pil") | ||
outputs = gr.outputs.Image(type="pil") | ||
... | ||
css=''' | ||
.gradio-container button.primary, .gradio-container button.plain { | ||
background: red; | ||
color: white; | ||
font-size: 15; | ||
font-weight: 500; | ||
} | ||
''' | ||
Borda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def __init__(self): | ||
super().__init__(css=self.css) | ||
self.ready = False | ||
``` | ||
|
||
You can also pass path to css file like this: | ||
Borda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```py | ||
class AnimeGANv2UI(ServeGradio): | ||
inputs = gr.inputs.Image(type="pil") | ||
outputs = gr.outputs.Image(type="pil") | ||
... | ||
css="styles.css" | ||
|
||
def __init__(self): | ||
super().__init__(css=self.css) | ||
Borda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.ready = False | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import gradio as gr | ||
|
||
import lightning as L | ||
from lightning.app.components.serve import ServeGradio | ||
|
||
|
||
class LitGradio(ServeGradio): | ||
inputs = [ | ||
gr.components.Textbox(label="print your prompt here", elem_id="label"), | ||
gr.components.Dropdown( | ||
label="choose you model", | ||
choices=[ | ||
"PulpSciFiDiffusion", | ||
"pixel_art_diffusion_hard_256", | ||
"pixel_art_diffusion_soft_256", | ||
], | ||
), | ||
gr.components.Number(value=250, label="number of steps"), | ||
gr.components.Audio(label="Audio"), | ||
gr.components.Image(label="Image"), | ||
gr.components.Video(label="Video"), | ||
gr.components.HTML(label="HTML"), | ||
gr.components.BarPlot(label="Bar Plot"), | ||
gr.components.Button(value="Hi"), | ||
gr.components.Chatbot(label="Bot"), | ||
gr.components.Checkbox(label="Checkbox"), | ||
gr.components.ColorPicker(label="Color Picker"), | ||
gr.components.File(label="File"), | ||
gr.components.Dataframe(label="Data Frame"), | ||
gr.components.Gallery(label="Gallery"), | ||
gr.components.HighlightedText( | ||
label="Highlighted Text", | ||
), | ||
gr.components.Image(label="Image"), | ||
gr.components.JSON(label="JSON"), | ||
gr.components.Label(label="Label"), | ||
gr.components.LinePlot(label="Line Plot"), | ||
gr.components.Markdown(label="Markdown"), | ||
gr.components.Model3D(label="Model 3D"), | ||
gr.components.Plot(label="Plot"), | ||
gr.components.Radio(label="Radio"), | ||
gr.components.ScatterPlot(label="Scatter Plot"), | ||
gr.components.Slider(label="Slider"), | ||
gr.components.Timeseries(label="Time Series"), | ||
gr.components.UploadButton(label="Upload Button"), | ||
gr.components.Video(label="Video"), | ||
] | ||
outputs = gr.outputs.Image(type="pil", label="Output Image") | ||
|
||
def predict(self, label, model, steps): | ||
return 0 | ||
|
||
def build_model(self): | ||
return None | ||
|
||
|
||
app = L.LightningApp(LitGradio()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
:root { | ||
--purple: rgb(121, 46, 229); | ||
--purple-darker: rgb(109, 30, 229); | ||
--button-primary-border-color-base: rgb(121, 46, 229); | ||
--purple-gradient: linear-gradient(206.91deg, rgb(121, 46, 229) 16.83%, rgb(62, 171, 179) 144.59%); | ||
--color-accent-base: var(--purple); | ||
--color-border-highlight: var(--purple); | ||
} | ||
|
||
.gradio-container { | ||
background: white; | ||
} | ||
|
||
.gradio-container input { | ||
font-size: 15px; | ||
border-radius: 6px; | ||
box-shadow: none; | ||
} | ||
|
||
.gradio-container button.primary, .gradio-container button.plain { | ||
background: var(--purple) !important; | ||
color: white !important; | ||
font-size: 15; | ||
} | ||
|
||
.gradio-container button.primary:hover, .gradio-container button.plain:hover { | ||
background: var(--purple-darker); | ||
color: white; | ||
} | ||
|
||
.gradio-container button.lg { | ||
border-radius: 120px; | ||
} | ||
|
||
.gradio-container input:focus { | ||
--tw-ring-opacity: 0; | ||
--tw-border-opacity: 0.5; | ||
box-shadow: none; | ||
border-color: var(--purple); | ||
} | ||
.gradio-container textarea:focus { | ||
--tw-ring-opacity: 0; | ||
--tw-border-opacity: 0.5; | ||
box-shadow: none; | ||
border-color: var(--purple); | ||
} | ||
|
||
.gradio-container input:hover { | ||
border-color: var(--purple); | ||
} | ||
|
||
.gradio-container input[type="range"] { | ||
accent-color: var(--purple); | ||
} | ||
|
||
.gradio-container input[type="checkbox"]:checked { | ||
background-color: var(--purple) !important; | ||
border-color: var(--purple) !important; | ||
} | ||
|
||
.gradio-container input[type="checkbox"]:focus { | ||
--ring-color: rgb(121, 46, 229 / .5) !important; | ||
border-color: var(--purple) !important; | ||
} | ||
|
||
.gradio-container button.sm.plain:hover svg { | ||
color: white !important; | ||
} | ||
|
||
.gradio-container .wrap:focus-within { | ||
border-color: var(--purple) !important; | ||
--ring-color: transparent !important; | ||
} | ||
|
||
.gradio-container th { | ||
border-color: var(--purple); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.