rhfeiyang commited on
Commit
36dcf5f
1 Parent(s): 3c07108
Files changed (1) hide show
  1. hf_demo.py +56 -53
hf_demo.py CHANGED
@@ -19,20 +19,20 @@ lora_map = {
19
  "Andre Derain (fauvism)": "andre-derain_subset1",
20
  "Vincent van Gogh (post impressionism)": "van_gogh_subset1",
21
  "Andy Warhol (pop art)": "andy_subset1",
22
- "Walter Battiss": "walter-battiss_subset2",
23
  "Camille Corot (realism)": "camille-corot_subset1",
24
  "Claude Monet (impressionism)": "monet_subset2",
25
  "Pablo Picasso (cubism)": "picasso_subset1",
26
- "Jackson Pollock": "jackson-pollock_subset1",
27
  "Gerhard Richter (abstract expressionism)": "gerhard-richter_subset1",
28
- "M.C. Escher": "m.c.-escher_subset1",
29
- "Albert Gleizes": "albert-gleizes_subset1",
30
  "Hokusai (ukiyo-e)": "katsushika-hokusai_subset1",
31
- "Wassily Kandinsky": "kandinsky_subset1",
32
  "Gustav Klimt (art nouveau)": "klimt_subset3",
33
- "Roy Lichtenstein": "roy-lichtenstein_subset1",
34
  "Henri Matisse (abstract expressionism)": "henri-matisse_subset1",
35
- "Joan Miro": "joan-miro_subset2",
36
  }
37
 
38
  @spaces.GPU
@@ -119,12 +119,11 @@ block = gr.Blocks()
119
  with block:
120
  with gr.Group():
121
  gr.Markdown(" # Art-Free Diffusion Demo")
122
- gr.Markdown("(More features in development...)")
123
  with gr.Row():
124
  text = gr.Textbox(
125
- label="Prompt (long and detailed would be better):",
126
  max_lines=10,
127
- placeholder="Enter your prompt (long and detailed would be better)",
128
  container=True,
129
  value="A beautiful garden with a large pond. The pond is surrounded by a wooden deck, and there are several chairs placed around the area. A stone fountain is present in the middle of the pond, adding to the serene atmosphere. The garden is decorated with a variety of potted plants, creating a lush and inviting environment. The scene is captured in a vibrant and colorful style, highlighting the natural beauty of the garden.",
130
  )
@@ -215,10 +214,9 @@ with block:
215
  adapter_choice = gr.Dropdown(
216
  label="Select Art Adapter",
217
  choices=[ "Andre Derain (fauvism)","Vincent van Gogh (post impressionism)","Andy Warhol (pop art)",
218
- "Camille Corot (realism)", "Claude Monet (impressionism)", "Pablo Picasso (cubism)", "Gerhard Richter (abstract expressionism)",
219
- "Hokusai (ukiyo-e)", "Gustav Klimt (art nouveau)", "Henri Matisse (abstract expressionism)",
220
- "Walter Battiss", "Jackson Pollock", "M.C. Escher", "Albert Gleizes", "Wassily Kandinsky",
221
- "Roy Lichtenstein", "Joan Miro"
222
  ],
223
  value="Andre Derain (fauvism)",
224
  scale=1
@@ -238,45 +236,50 @@ with block:
238
  gr.on([btn_style_ori.click], demo_inference_stylization_ori, inputs=[gallery_stylization_ref, text, seed, steps, scale, start_timestep], outputs=gallery_stylization_ori)
239
  gr.on([btn_style_art.click], demo_inference_stylization_artistic, inputs=[gallery_stylization_ref, adapter_choice, text, seed, steps, scale, adapter_scale, start_timestep], outputs=gallery_stylization_art)
240
 
241
- examples = gr.Examples(
242
- examples=[
243
- ["Snow-covered trees with sunlight shining through",
244
- "data/Snow-covered_trees_with_sunlight_shining_through.jpg",
245
- 0,
246
- ],
247
- ["A picturesque landscape showcasing a winding river cutting through a lush green valley, surrounded by rugged mountains under a clear blue sky. The mix of red and brown tones in the rocky hills adds to the region's natural beauty and diversity.",
248
- "data/0011772.jpg",
249
- 528741066,
250
- ],
251
- ["A black SUV driving down a highway with a scenic view of mountains and water in the background. The SUV is the main focus of the image, and it appears to be traveling at a moderate speed. The road is well-maintained and provides a smooth driving experience. The mountains and water create a picturesque backdrop, adding to the overall beauty of the scene. The image captures the essence of a leisurely road trip, with the SUV as the primary subject, highlighting the sense of adventure and exploration that comes with such journeys.",
252
- "data/a_black_SUV_driving_down_a_highway_with_a_scenic_view_of_mountains_and_water_in_the_background._The_.jpg",
253
- 299739226,
254
- ],
255
- ["A beautiful garden with a large pond. The pond is surrounded by a wooden deck, and there are several chairs placed around the area. A stone fountain is present in the middle of the pond, adding to the serene atmosphere. The garden is decorated with a variety of potted plants, creating a lush and inviting environment. The scene is captured in a vibrant and colorful style, highlighting the natural beauty of the garden.",
256
- "data/a_beautiful_garden_with_a_large_pond._The_pond_is_surrounded_by_a_wooden_deck,_and_there_are_several.jpg",
257
- 38541490,
258
- ],
259
- [
260
- "A blue bench situated in a park, surrounded by trees and leaves. The bench is positioned under a tree, providing shade and a peaceful atmosphere. There are several benches in the park, with one being closer to the foreground and the others further in the background. A person can be seen in the distance, possibly enjoying the park or taking a walk. The overall scene is serene and inviting, with the bench serving as a focal point in the park's landscape.",
261
- "data/003904765.jpg",
262
- 3904764,
263
- ]
264
-
265
- ],
266
- inputs=[
267
- text,
268
- gallery_stylization_ref,
269
- seed,
270
- adapter_choice,
271
- steps,
272
- scale,
273
- adapter_scale,
274
- start_timestep,
275
- ],
276
- fn=demo_inference_all,
277
- outputs=[gallery_gen_ori, gallery_gen_art, gallery_stylization_ori, gallery_stylization_art],
278
- cache_examples=True,
279
- )
 
 
 
 
 
280
 
281
  block.launch()
282
  # block.launch(sharing=True)
 
19
  "Andre Derain (fauvism)": "andre-derain_subset1",
20
  "Vincent van Gogh (post impressionism)": "van_gogh_subset1",
21
  "Andy Warhol (pop art)": "andy_subset1",
22
+ "Walter Battiss (abstract expressionism)": "walter-battiss_subset2",
23
  "Camille Corot (realism)": "camille-corot_subset1",
24
  "Claude Monet (impressionism)": "monet_subset2",
25
  "Pablo Picasso (cubism)": "picasso_subset1",
26
+ "Jackson Pollock (abstract expressionism)": "jackson-pollock_subset1",
27
  "Gerhard Richter (abstract expressionism)": "gerhard-richter_subset1",
28
+ "M.C. Escher (woodcut surrealism)": "m.c.-escher_subset1",
29
+ "Albert Gleizes (cubism)": "albert-gleizes_subset1",
30
  "Hokusai (ukiyo-e)": "katsushika-hokusai_subset1",
31
+ "Wassily Kandinsky (abstract expressionism)": "kandinsky_subset1",
32
  "Gustav Klimt (art nouveau)": "klimt_subset3",
33
+ "Roy Lichtenstein (pop art)": "roy-lichtenstein_subset1",
34
  "Henri Matisse (abstract expressionism)": "henri-matisse_subset1",
35
+ "Joan Miro (surrealism and abstract art)": "joan-miro_subset2",
36
  }
37
 
38
  @spaces.GPU
 
119
  with block:
120
  with gr.Group():
121
  gr.Markdown(" # Art-Free Diffusion Demo")
 
122
  with gr.Row():
123
  text = gr.Textbox(
124
+ label="Prompt:",
125
  max_lines=10,
126
+ placeholder="Enter your prompt",
127
  container=True,
128
  value="A beautiful garden with a large pond. The pond is surrounded by a wooden deck, and there are several chairs placed around the area. A stone fountain is present in the middle of the pond, adding to the serene atmosphere. The garden is decorated with a variety of potted plants, creating a lush and inviting environment. The scene is captured in a vibrant and colorful style, highlighting the natural beauty of the garden.",
129
  )
 
214
  adapter_choice = gr.Dropdown(
215
  label="Select Art Adapter",
216
  choices=[ "Andre Derain (fauvism)","Vincent van Gogh (post impressionism)","Andy Warhol (pop art)",
217
+ "Camille Corot (realism)", "Claude Monet (impressionism)", "Pablo Picasso (cubism)", "Hokusai (ukiyo-e)", "Gustav Klimt (art nouveau)", "Henri Matisse (abstract expressionism)", "Gerhard Richter (abstract expressionism)", "Wassily Kandinsky (abstract expressionism)",
218
+ "Walter Battiss (abstract expressionism)", "Jackson Pollock (abstract expressionism)", "M.C. Escher (woodcut surrealism)", "Albert Gleizes (cubism)",
219
+ "Roy Lichtenstein (pop art)", "Joan Miro (surrealism and abstract art)"
 
220
  ],
221
  value="Andre Derain (fauvism)",
222
  scale=1
 
236
  gr.on([btn_style_ori.click], demo_inference_stylization_ori, inputs=[gallery_stylization_ref, text, seed, steps, scale, start_timestep], outputs=gallery_stylization_ori)
237
  gr.on([btn_style_art.click], demo_inference_stylization_artistic, inputs=[gallery_stylization_ref, adapter_choice, text, seed, steps, scale, adapter_scale, start_timestep], outputs=gallery_stylization_art)
238
 
239
+
240
+ with gr.Group():
241
+ gr.Markdown(" # Examples")
242
+ gr.Markdown("The model performs best when provided with long, detailed captions. For optimal image quality, describe the scene with specific details about objects, settings, colors, lighting, and emotions. Below are examples of how detailed captions enhance the output quality.")
243
+ examples = gr.Examples(
244
+ examples=[
245
+ ["Snow-covered trees with sunlight shining through",
246
+ "data/Snow-covered_trees_with_sunlight_shining_through.jpg",
247
+ 0,
248
+ ],
249
+ ["A picturesque landscape showcasing a winding river cutting through a lush green valley, surrounded by rugged mountains under a clear blue sky. The mix of red and brown tones in the rocky hills adds to the region's natural beauty and diversity.",
250
+ "data/0011772.jpg",
251
+ 528741066,
252
+ ],
253
+ ["A black SUV driving down a highway with a scenic view of mountains and water in the background. The SUV is the main focus of the image, and it appears to be traveling at a moderate speed. The road is well-maintained and provides a smooth driving experience. The mountains and water create a picturesque backdrop, adding to the overall beauty of the scene. The image captures the essence of a leisurely road trip, with the SUV as the primary subject, highlighting the sense of adventure and exploration that comes with such journeys.",
254
+ "data/a_black_SUV_driving_down_a_highway_with_a_scenic_view_of_mountains_and_water_in_the_background._The_.jpg",
255
+ 299739226,
256
+ ],
257
+ ["A beautiful garden with a large pond. The pond is surrounded by a wooden deck, and there are several chairs placed around the area. A stone fountain is present in the middle of the pond, adding to the serene atmosphere. The garden is decorated with a variety of potted plants, creating a lush and inviting environment. The scene is captured in a vibrant and colorful style, highlighting the natural beauty of the garden.",
258
+ "data/a_beautiful_garden_with_a_large_pond._The_pond_is_surrounded_by_a_wooden_deck,_and_there_are_several.jpg",
259
+ 38541490,
260
+ ],
261
+ [
262
+ "A blue bench situated in a park, surrounded by trees and leaves. The bench is positioned under a tree, providing shade and a peaceful atmosphere. There are several benches in the park, with one being closer to the foreground and the others further in the background. A person can be seen in the distance, possibly enjoying the park or taking a walk. The overall scene is serene and inviting, with the bench serving as a focal point in the park's landscape.",
263
+ "data/003904765.jpg",
264
+ 3904764,
265
+ ]
266
+
267
+ ],
268
+ inputs=[
269
+ text,
270
+ gallery_stylization_ref,
271
+ seed,
272
+ adapter_choice,
273
+ steps,
274
+ scale,
275
+ adapter_scale,
276
+ start_timestep,
277
+ ],
278
+ fn=demo_inference_all,
279
+ outputs=[gallery_gen_ori, gallery_gen_art, gallery_stylization_ori, gallery_stylization_art],
280
+ cache_examples=True,
281
+ label="Click the example to see the result"
282
+ )
283
 
284
  block.launch()
285
  # block.launch(sharing=True)