gaur3009 commited on
Commit
7ebcf88
·
verified ·
1 Parent(s): ae20856

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -29
app.py CHANGED
@@ -18,16 +18,13 @@ else:
18
  MAX_SEED = np.iinfo(np.int32).max
19
  MAX_IMAGE_SIZE = 1024
20
 
21
- def infer(color, dress_type, front_design, back_design, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
22
  if randomize_seed:
23
  seed = random.randint(0, MAX_SEED)
24
 
25
  generator = torch.Generator().manual_seed(seed)
26
 
27
- prompt_base = f"a single {color} colored plain {dress_type} with design, hanging on the plain wall"
28
- front_prompt = f"front view of {prompt_base} with {front_design} design"
29
- back_prompt = f"back view of {prompt_base} with {back_design} design"
30
-
31
  front_image = pipe(
32
  prompt=front_prompt,
33
  negative_prompt=negative_prompt,
@@ -38,6 +35,7 @@ def infer(color, dress_type, front_design, back_design, negative_prompt, seed, r
38
  generator=generator
39
  ).images[0]
40
 
 
41
  back_image = pipe(
42
  prompt=back_prompt,
43
  negative_prompt=negative_prompt,
@@ -78,42 +76,63 @@ with gr.Blocks(css=css) as demo:
78
 
79
  with gr.Row():
80
 
81
- color = gr.Textbox(
82
- label="Color",
83
- show_label=True,
 
 
 
 
 
 
 
 
 
 
84
  max_lines=1,
85
- placeholder="Color (e.g., red, blue)",
86
  container=False,
87
  )
88
 
89
- dress_type = gr.Textbox(
90
- label="Dress Type",
91
- show_label=True,
92
  max_lines=1,
93
- placeholder="Dress type (e.g., t-shirt, sweatshirt, shirt, hoodie)",
94
  container=False,
95
  )
96
 
97
- front_design = gr.Textbox(
98
- label="Front Design",
99
- show_label=True,
100
  max_lines=1,
101
- placeholder="Front design",
102
  container=False,
103
  )
104
 
105
- back_design = gr.Textbox(
106
- label="Back Design",
107
- show_label=True,
108
  max_lines=1,
109
- placeholder="Back design",
110
  container=False,
111
  )
112
 
 
 
 
 
 
 
 
 
 
 
 
113
  run_button = gr.Button("Run", scale=0)
114
 
115
- front_result = gr.Image(label="Front View Result", show_label=True)
116
- back_result = gr.Image(label="Back View Result", show_label=True)
117
 
118
  with gr.Accordion("Advanced Settings", open=False):
119
 
@@ -121,7 +140,7 @@ with gr.Blocks(css=css) as demo:
121
  label="Negative prompt",
122
  max_lines=1,
123
  placeholder="Enter a negative prompt",
124
- visible=True,
125
  )
126
 
127
  seed = gr.Slider(
@@ -165,20 +184,20 @@ with gr.Blocks(css=css) as demo:
165
  num_inference_steps = gr.Slider(
166
  label="Number of inference steps",
167
  minimum=1,
168
- maximum=50,
169
  step=1,
170
- value=20,
171
  )
172
 
173
  gr.Examples(
174
  examples=examples,
175
- inputs=[color, dress_type, front_design, back_design]
176
  )
177
 
178
  run_button.click(
179
  fn=infer,
180
- inputs=[color, dress_type, front_design, back_design, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
181
  outputs=[front_result, back_result]
182
  )
183
 
184
- demo.queue().launch()
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
  MAX_IMAGE_SIZE = 1024
20
 
21
+ def infer(prompt_part1, color, dress_type, front_design, back_design, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
22
  if randomize_seed:
23
  seed = random.randint(0, MAX_SEED)
24
 
25
  generator = torch.Generator().manual_seed(seed)
26
 
27
+ front_prompt = f"front view of {prompt_part1} {color} colored plain {dress_type} with {front_design} design, {prompt_part5}"
 
 
 
28
  front_image = pipe(
29
  prompt=front_prompt,
30
  negative_prompt=negative_prompt,
 
35
  generator=generator
36
  ).images[0]
37
 
38
+ back_prompt = f"back view of {prompt_part1} {color} colored plain {dress_type} with {back_design} design, {prompt_part5}"
39
  back_image = pipe(
40
  prompt=back_prompt,
41
  negative_prompt=negative_prompt,
 
76
 
77
  with gr.Row():
78
 
79
+ prompt_part1 = gr.Textbox(
80
+ value="a single",
81
+ label="Prompt Part 1",
82
+ show_label=False,
83
+ interactive=False,
84
+ container=False,
85
+ elem_id="prompt_part1",
86
+ visible=False,
87
+ )
88
+
89
+ prompt_part2 = gr.Textbox(
90
+ label="color",
91
+ show_label=False,
92
  max_lines=1,
93
+ placeholder="color (e.g., color category)",
94
  container=False,
95
  )
96
 
97
+ prompt_part3 = gr.Textbox(
98
+ label="dress_type",
99
+ show_label=False,
100
  max_lines=1,
101
+ placeholder="dress_type (e.g., t-shirt, sweatshirt, shirt, hoodie)",
102
  container=False,
103
  )
104
 
105
+ prompt_part4_front = gr.Textbox(
106
+ label="front design",
107
+ show_label=False,
108
  max_lines=1,
109
+ placeholder="front design",
110
  container=False,
111
  )
112
 
113
+ prompt_part4_back = gr.Textbox(
114
+ label="back design",
115
+ show_label=False,
116
  max_lines=1,
117
+ placeholder="back design",
118
  container=False,
119
  )
120
 
121
+ prompt_part5 = gr.Textbox(
122
+ value="hanging on the plain wall",
123
+ label="Prompt Part 5",
124
+ show_label=False,
125
+ interactive=False,
126
+ container=False,
127
+ elem_id="prompt_part5",
128
+ visible=False,
129
+ )
130
+
131
+
132
  run_button = gr.Button("Run", scale=0)
133
 
134
+ front_result = gr.Image(label="Front View Result", show_label=False)
135
+ back_result = gr.Image(label="Back View Result", show_label=False)
136
 
137
  with gr.Accordion("Advanced Settings", open=False):
138
 
 
140
  label="Negative prompt",
141
  max_lines=1,
142
  placeholder="Enter a negative prompt",
143
+ visible=False,
144
  )
145
 
146
  seed = gr.Slider(
 
184
  num_inference_steps = gr.Slider(
185
  label="Number of inference steps",
186
  minimum=1,
187
+ maximum=12,
188
  step=1,
189
+ value=2,
190
  )
191
 
192
  gr.Examples(
193
  examples=examples,
194
+ inputs=[prompt_part2, prompt_part3, prompt_part4_front, prompt_part4_back]
195
  )
196
 
197
  run_button.click(
198
  fn=infer,
199
+ inputs=[prompt_part1, prompt_part2, prompt_part3, prompt_part4_front, prompt_part4_back, prompt_part5, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
200
  outputs=[front_result, back_result]
201
  )
202
 
203
+ demo.queue().launch()