ysharma HF staff commited on
Commit
c3f2272
1 Parent(s): 425a11d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -10
app.py CHANGED
@@ -23,8 +23,7 @@ sa_args = sa_handler.StyleAlignedArgs(share_group_norm=False,
23
 
24
  handler.register(sa_args, )
25
 
26
-
27
- # run StyleAligned
28
  sets_of_prompts = [
29
  "a toy train. macro photo. 3d game asset",
30
  "a toy airplane. macro photo. 3d game asset",
@@ -33,20 +32,44 @@ sets_of_prompts = [
33
  "a toy boat. macro photo. 3d game asset",
34
  ]
35
 
36
- def style_aligned_sdxl(prompt):
37
- images = pipeline([prompt],).images
 
 
38
  #mediapy.show_images(images)
39
  print(images)
40
- return images[0]
41
 
42
  with gr.Blocks() as demo:
43
  with gr.Group():
44
- with gr.Row():
45
- prompt = gr.Textbox(label="Prompt", scale=8)
46
- btn = gr.Button("Greet", scale=2)
47
- output = gr.Image(label="Style-Aligned SDXL", type='pil')
 
 
 
 
 
 
 
 
48
 
49
- btn.click(fn=style_aligned_sdxl, inputs=prompt, outputs=output, api_name="style_aligned_sdxl")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  demo.launch()
52
 
 
23
 
24
  handler.register(sa_args, )
25
 
26
+ # example of set of prompts
 
27
  sets_of_prompts = [
28
  "a toy train. macro photo. 3d game asset",
29
  "a toy airplane. macro photo. 3d game asset",
 
32
  "a toy boat. macro photo. 3d game asset",
33
  ]
34
 
35
+ # run StyleAligned
36
+ def style_aligned_sdxl(initial_prompt1, initial_prompt2, initial_prompt3, initial_prompt4, initial_prompt5, style_prompt):
37
+ sets_of_prompts = [ prompt + ". " + style_prompt for prompt in [initial_prompt1, initial_prompt2, initial_prompt3, initial_prompt4, initial_prompt5,]]
38
+ images = pipeline(sets_of_prompts,).images
39
  #mediapy.show_images(images)
40
  print(images)
41
+ return images
42
 
43
  with gr.Blocks() as demo:
44
  with gr.Group():
45
+ with gr.Column():
46
+ with gr.Accordion(label='Enter upto 5 different initial prompts', open=True):
47
+ with gr.Row():
48
+ initial_prompt1 = gr.Textbox(value='', show_label=False, container=False, placeholder='a toy train')
49
+ initial_prompt2 = gr.Textbox(value='', show_label=False, container=False, placeholder='a toy airplane')
50
+ initial_prompt3 = gr.Textbox(value='', show_label=False, container=False, placeholder='a toy bicycle')
51
+ initial_prompt4 = gr.Textbox(value='', show_label=False, container=False, placeholder='a toy car')
52
+ initial_prompt5 = gr.Textbox(value='', show_label=False, container=False, placeholder='a toy boat')
53
+ with gr.Row():
54
+ style_prompt = gr.Textbox(label="Enter a style prompt", placeholder='macro photo, 3d game asset')
55
+ btn = gr.Button("Generate a set of Style-aligned SDXL images",)
56
+ output = gr.Gallery(label="Style-Aligned SDXL", )
57
 
58
+ btn.click(fn=style_aligned_sdxl,
59
+ inputs=[initial_prompt1, initial_prompt2, initial_prompt3, initial_prompt4, initial_prompt5, style_prompt],
60
+ outputs=output,
61
+ api_name="style_aligned_sdxl")
62
+
63
+ gr.Examples(examples=[
64
+ ["a toy train", "a toy airplane", "a toy bicycle", "a toy car", "a toy boat", "macro photo. 3d game asset."],
65
+ ["a toy train", "a toy airplane", "a toy bicycle", "a toy car", "a toy boat", "BW logo. high contrast."],
66
+ ["a cat", "a dog", "a bear", "a man on a bicycle", "a girl working on laptop", "minimal origami."],
67
+ ["Firewoman", "Gradner", "Scientist", "Policewoman", "Saxophone player", "made of claymation, stop motion animation."],
68
+ ["Firewoman", "Gradner", "Scientist", "Policewoman", "Saxophone player", "sketch, character sheet."],
69
+ ],
70
+ inputs=[initial_prompt1, initial_prompt2, initial_prompt3, initial_prompt4, initial_prompt5, style_prompt],
71
+ outputs=[output],
72
+ fn=style_aligned_sdxl)
73
 
74
  demo.launch()
75