tombetthauser commited on
Commit
c91c54c
Β·
1 Parent(s): cd7f3ee

Add styles dropdown

Browse files
Files changed (1) hide show
  1. app.py +12 -4
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
- def image_prompt(thing):
18
- prompt = "A children's drawing of a " + thing
 
 
 
 
 
 
 
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
- animal = gradio.Textbox(label="generate a children's drawing of a...", elem_id="input-text")
 
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=animal, outputs=output)
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()