Spaces:
Runtime error
Runtime error
Commit
Β·
c91c54c
1
Parent(s):
cd7f3ee
Add styles dropdown
Browse files
app.py
CHANGED
@@ -14,8 +14,15 @@ my_token = api_key
|
|
14 |
with init_empty_weights():
|
15 |
pipe = pipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=my_token).to("cuda")
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
return pipe(prompt=prompt, height=512, width=664).images[0]
|
20 |
|
21 |
with gradio.Blocks(css="""
|
@@ -89,9 +96,10 @@ with gradio.Blocks(css="""
|
|
89 |
border-radius: 0;
|
90 |
}
|
91 |
""") as demo:
|
92 |
-
|
|
|
93 |
output = gradio.Image(elem_id="output-image")
|
94 |
go_button = gradio.Button("draw it!", elem_id="go-button")
|
95 |
-
go_button.click(fn=image_prompt, inputs=
|
96 |
|
97 |
demo.launch()
|
|
|
14 |
with init_empty_weights():
|
15 |
pipe = pipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision="fp16", torch_dtype=torch.float16, use_auth_token=my_token).to("cuda")
|
16 |
|
17 |
+
DROPDOWNS = {
|
18 |
+
"gustav": " by dan mumford and gustav klimt and john harris and jean delville and victo ngai and josan gonzalez",
|
19 |
+
"hiyao": " by studio ghibli, by miyazaki, watercolor painting",
|
20 |
+
"vinny": " painting by Vincent van Gogh",
|
21 |
+
"kids": " drawn by a child",
|
22 |
+
}
|
23 |
+
|
24 |
+
def image_prompt(prompt, dropdown):
|
25 |
+
prompt = prompt + DROPDOWNS[dropdown]
|
26 |
return pipe(prompt=prompt, height=512, width=664).images[0]
|
27 |
|
28 |
with gradio.Blocks(css="""
|
|
|
96 |
border-radius: 0;
|
97 |
}
|
98 |
""") as demo:
|
99 |
+
dropdown = gradio.Dropdown(["danny", "gustav", "hiyao", "vinny"])
|
100 |
+
prompt = gradio.Textbox(label="image prompt...", elem_id="input-text")
|
101 |
output = gradio.Image(elem_id="output-image")
|
102 |
go_button = gradio.Button("draw it!", elem_id="go-button")
|
103 |
+
go_button.click(fn=image_prompt, inputs=[prompt, dropdown], outputs=output)
|
104 |
|
105 |
demo.launch()
|