awacke1 commited on
Commit
9e21cc4
·
verified ·
1 Parent(s): cabb8e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -5
app.py CHANGED
@@ -71,6 +71,13 @@ def vote(filename, vote_type):
71
  save_vote_counts(vote_counts)
72
  return get_image_gallery()
73
 
 
 
 
 
 
 
 
74
  MAX_SEED = np.iinfo(np.int32).max
75
 
76
  if not torch.cuda.is_available():
@@ -125,9 +132,19 @@ def generate(
125
 
126
  return image_paths, seed, download_links, get_image_gallery()
127
 
128
- examples = [
129
- "A bustling cityscape at sunset, where sleek, translucent skyscrapers shimmer with holographic displays. Gentle AI-powered drones weave through the air, delivering packages and tending to floating gardens. In the foreground, a diverse group of humans and lifelike androids share a laugh at a streetside café, their animated conversation bringing warmth to the scene.",
130
- # ... (other examples remain unchanged)
 
 
 
 
 
 
 
 
 
 
131
  ]
132
 
133
  css = '''
@@ -205,14 +222,36 @@ with gr.Blocks(css=css, theme="pseudolab/huggingface-korea-theme") as demo:
205
 
206
  selected_image = gr.State(None)
207
 
208
- gr.Examples(
209
- examples=examples,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  inputs=prompt,
211
  outputs=[result, seed],
212
  fn=generate,
213
  cache_examples=False,
214
  )
215
 
 
 
 
 
 
 
216
  use_negative_prompt.change(
217
  fn=lambda x: gr.update(visible=x),
218
  inputs=use_negative_prompt,
 
71
  save_vote_counts(vote_counts)
72
  return get_image_gallery()
73
 
74
+ def get_random_style():
75
+ styles = [
76
+ "Impressionist", "Cubist", "Surrealist", "Abstract Expressionist",
77
+ "Pop Art", "Minimalist", "Baroque", "Art Nouveau", "Pointillist", "Fauvism"
78
+ ]
79
+ return random.choice(styles)
80
+
81
  MAX_SEED = np.iinfo(np.int32).max
82
 
83
  if not torch.cuda.is_available():
 
132
 
133
  return image_paths, seed, download_links, get_image_gallery()
134
 
135
+ example_sets = [
136
+ [
137
+ f"{get_random_style()} painting of a majestic lighthouse on a rocky coast. Use bold brushstrokes and a vibrant color palette to capture the interplay of light and shadow as the lighthouse beam cuts through a stormy night sky.",
138
+ f"{get_random_style()} still life featuring a pair of vintage eyeglasses. Focus on the intricate details of the frames and lenses, using a warm color scheme to evoke a sense of nostalgia and wisdom.",
139
+ f"{get_random_style()} depiction of a rustic wooden stool in a sunlit artist's studio. Emphasize the texture of the wood and the interplay of light and shadow, using a mix of earthy tones and highlights.",
140
+ f"{get_random_style()} scene viewed through an ornate window frame. Contrast the intricate details of the window with a dreamy, soft-focus landscape beyond, using a palette that transitions from cool interior tones to warm exterior hues.",
141
+ f"{get_random_style()} close-up study of interlaced fingers. Use a monochromatic color scheme to emphasize the form and texture of the hands, with dramatic lighting to create depth and emotion.",
142
+ f"{get_random_style()} composition featuring a set of dice in motion. Capture the energy and randomness of the throw, using a dynamic color palette and blurred lines to convey movement.",
143
+ f"{get_random_style()} interpretation of heaven. Create an ethereal atmosphere with soft, billowing clouds and radiant light, using a palette of celestial blues, golds, and whites.",
144
+ f"{get_random_style()} portrayal of an ancient, mystical gate. Combine architectural details with elements of fantasy, using a rich, jewel-toned palette to create an air of mystery and magic.",
145
+ f"{get_random_style()} portrait of a curious cat. Focus on capturing the feline's expressive eyes and sleek form, using a mix of bold and subtle colors to bring out the cat's personality.",
146
+ f"{get_random_style()} abstract representation of toes in sand. Use textured brushstrokes to convey the feeling of warm sand, with a palette inspired by a sun-drenched beach."
147
+ ] for _ in range(3)
148
  ]
149
 
150
  css = '''
 
222
 
223
  selected_image = gr.State(None)
224
 
225
+ example_set_dropdown = gr.Dropdown(
226
+ choices=["Set 1", "Set 2", "Set 3"],
227
+ label="Select Example Set",
228
+ value="Set 1"
229
+ )
230
+
231
+ def update_examples(choice):
232
+ set_index = int(choice.split()[-1]) - 1
233
+ return gr.Examples(
234
+ examples=example_sets[set_index],
235
+ inputs=prompt,
236
+ outputs=[result, seed],
237
+ fn=generate,
238
+ cache_examples=False,
239
+ )
240
+
241
+ examples_component = gr.Examples(
242
+ examples=example_sets[0],
243
  inputs=prompt,
244
  outputs=[result, seed],
245
  fn=generate,
246
  cache_examples=False,
247
  )
248
 
249
+ example_set_dropdown.change(
250
+ fn=update_examples,
251
+ inputs=[example_set_dropdown],
252
+ outputs=[examples_component]
253
+ )
254
+
255
  use_negative_prompt.change(
256
  fn=lambda x: gr.update(visible=x),
257
  inputs=use_negative_prompt,