NikhilJoson commited on
Commit
b712951
·
verified ·
1 Parent(s): 647b23c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -201
app.py CHANGED
@@ -38,7 +38,7 @@ def predict_clothing(images):
38
 
39
  @spaces.GPU(duration=180)
40
  def generate_image(img1, img2, img3, height, width, img_guidance_scale, inference_steps, seed, separate_cfg_infer, offload_model,
41
- use_input_image_size_as_output, max_input_image_size, randomize_seed, guidance_scale=3.5):
42
 
43
  input_images = [img1, img2, img3]
44
  # Delete None
@@ -68,215 +68,34 @@ def generate_image(img1, img2, img3, height, width, img_guidance_scale, inferenc
68
  img = output[0]
69
  return img
70
 
 
71
  def get_example():
72
  case = [
73
- [
74
- "A curly-haired man in a red shirt is drinking tea.",
75
- None,
76
- None,
77
- None,
78
- 1024,
79
- 1024,
80
- 2.5,
81
- 1.6,
82
- 0,
83
- 1024,
84
- False,
85
- False,
86
- ],
87
- [
88
- "The woman in <img><|image_1|></img> waves her hand happily in the crowd",
89
- "./imgs/test_cases/zhang.png",
90
- None,
91
- None,
92
- 1024,
93
- 1024,
94
- 2.5,
95
- 1.9,
96
- 128,
97
- 1024,
98
- False,
99
- False,
100
- ],
101
- [
102
- "A man in a black shirt is reading a book. The man is the right man in <img><|image_1|></img>.",
103
- "./imgs/test_cases/two_man.jpg",
104
- None,
105
- None,
106
- 1024,
107
- 1024,
108
- 2.5,
109
- 1.6,
110
- 0,
111
- 1024,
112
- False,
113
- False,
114
- ],
115
- [
116
- "Two woman are raising fried chicken legs in a bar. A woman is <img><|image_1|></img>. Another woman is <img><|image_2|></img>.",
117
- "./imgs/test_cases/mckenna.jpg",
118
- "./imgs/test_cases/Amanda.jpg",
119
- None,
120
- 1024,
121
- 1024,
122
- 2.5,
123
- 1.8,
124
- 65,
125
- 1024,
126
- False,
127
- False,
128
- ],
129
- [
130
- "A man and a short-haired woman with a wrinkled face are standing in front of a bookshelf in a library. The man is the man in the middle of <img><|image_1|></img>, and the woman is oldest woman in <img><|image_2|></img>",
131
- "./imgs/test_cases/1.jpg",
132
- "./imgs/test_cases/2.jpg",
133
- None,
134
- 1024,
135
- 1024,
136
- 2.5,
137
- 1.6,
138
- 60,
139
- 1024,
140
- False,
141
- False,
142
- ],
143
- [
144
- "A man and a woman are sitting at a classroom desk. The man is the man with yellow hair in <img><|image_1|></img>. The woman is the woman on the left of <img><|image_2|></img>",
145
- "./imgs/test_cases/3.jpg",
146
- "./imgs/test_cases/4.jpg",
147
- None,
148
- 1024,
149
- 1024,
150
- 2.5,
151
- 1.8,
152
- 66,
153
- 1024,
154
- False,
155
- False,
156
- ],
157
- [
158
- "The flower <img><|image_1|></img> is placed in the vase which is in the middle of <img><|image_2|></img> on a wooden table of a living room",
159
- "./imgs/test_cases/rose.jpg",
160
- "./imgs/test_cases/vase.jpg",
161
- None,
162
- 1024,
163
- 1024,
164
- 2.5,
165
- 1.6,
166
- 0,
167
- 1024,
168
- False,
169
- False,
170
- ],
171
- [
172
- "<img><|image_1|><img>\n Remove the woman's earrings. Replace the mug with a clear glass filled with sparkling iced cola.",
173
- "./imgs/demo_cases/t2i_woman_with_book.png",
174
- None,
175
- None,
176
- None,
177
- None,
178
- 2.5,
179
- 1.6,
180
- 222,
181
- 1024,
182
- False,
183
- True,
184
- ],
185
- [
186
- "Detect the skeleton of human in this image: <img><|image_1|></img>.",
187
- "./imgs/test_cases/control.jpg",
188
- None,
189
- None,
190
- 1024,
191
- 1024,
192
- 2.0,
193
- 1.6,
194
- 0,
195
- 1024,
196
- False,
197
- True,
198
- ],
199
- [
200
- "Generate a new photo using the following picture and text as conditions: <img><|image_1|><img>\n A young boy is sitting on a sofa in the library, holding a book. His hair is neatly combed, and a faint smile plays on his lips, with a few freckles scattered across his cheeks. The library is quiet, with rows of shelves filled with books stretching out behind him.",
201
- "./imgs/demo_cases/skeletal.png",
202
- None,
203
- None,
204
- 1024,
205
- 1024,
206
- 2,
207
- 1.6,
208
- 999,
209
- 1024,
210
- False,
211
- True,
212
- ],
213
- [
214
- "Following the pose of this image <img><|image_1|><img>, generate a new photo: A young boy is sitting on a sofa in the library, holding a book. His hair is neatly combed, and a faint smile plays on his lips, with a few freckles scattered across his cheeks. The library is quiet, with rows of shelves filled with books stretching out behind him.",
215
- "./imgs/demo_cases/edit.png",
216
- None,
217
- None,
218
- 1024,
219
- 1024,
220
- 2.0,
221
- 1.6,
222
- 123,
223
- 1024,
224
- False,
225
- True,
226
- ],
227
- [
228
- "Following the depth mapping of this image <img><|image_1|><img>, generate a new photo: A young girl is sitting on a sofa in the library, holding a book. His hair is neatly combed, and a faint smile plays on his lips, with a few freckles scattered across his cheeks. The library is quiet, with rows of shelves filled with books stretching out behind him.",
229
- "./imgs/demo_cases/edit.png",
230
- None,
231
- None,
232
- 1024,
233
- 1024,
234
- 2.0,
235
- 1.6,
236
- 1,
237
- 1024,
238
- False,
239
- True,
240
- ],
241
- [
242
- "<img><|image_1|><\/img> What item can be used to see the current time? Please highlight it in blue.",
243
- "./imgs/test_cases/watch.jpg",
244
- None,
245
- None,
246
- 1024,
247
- 1024,
248
- 2.5,
249
- 1.6,
250
- 666,
251
- 1024,
252
- False,
253
- True,
254
- ],
255
- [
256
- "According to the following examples, generate an output for the input.\nInput: <img><|image_1|></img>\nOutput: <img><|image_2|></img>\n\nInput: <img><|image_3|></img>\nOutput: ",
257
- "./imgs/test_cases/icl1.jpg",
258
- "./imgs/test_cases/icl2.jpg",
259
- "./imgs/test_cases/icl3.jpg",
260
- 224,
261
- 224,
262
- 2.5,
263
- 1.6,
264
- 1,
265
- 768,
266
- False,
267
- False,
268
- ],
269
  ]
270
  return case
271
 
272
- def run_for_examples(text, img1, img2, img3, height, width, guidance_scale, img_guidance_scale, seed, max_input_image_size, randomize_seed, use_input_image_size_as_output):
 
273
  # Check the internal configuration of the function
274
  inference_steps = 50
275
  separate_cfg_infer = True
276
  offload_model = False
277
-
278
- return generate_image(text, img1, img2, img3, height, width, guidance_scale, img_guidance_scale, inference_steps, seed,
279
- separate_cfg_infer, offload_model, use_input_image_size_as_output, max_input_image_size, randomize_seed)
 
280
 
281
  description = """
282
  This is a Virtual Try-On Platform.
 
38
 
39
  @spaces.GPU(duration=180)
40
  def generate_image(img1, img2, img3, height, width, img_guidance_scale, inference_steps, seed, separate_cfg_infer, offload_model,
41
+ use_input_image_size_as_output, max_input_image_size, randomize_seed, guidance_scale=3):
42
 
43
  input_images = [img1, img2, img3]
44
  # Delete None
 
68
  img = output[0]
69
  return img
70
 
71
+ example_text =
72
  def get_example():
73
  case = [
74
+ [ "./imgs/test_cases/icl1.jpg",
75
+ "./imgs/test_cases/icl2.jpg",
76
+ "./imgs/test_cases/icl3.jpg",
77
+ 224,
78
+ 224,
79
+ 1.6,
80
+ 1,
81
+ 768,
82
+ False,
83
+ False,
84
+ 2.5
85
+ ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  ]
87
  return case
88
 
89
+ def run_for_examples(img1, img2, img3, height, width, img_guidance_scale, seed, max_input_image_size, randomize_seed,
90
+ use_input_image_size_as_output, guidance_scale==3):
91
  # Check the internal configuration of the function
92
  inference_steps = 50
93
  separate_cfg_infer = True
94
  offload_model = False
95
+
96
+ text = "According to the following examples, generate an output for the input.\nInput: <img><|image_1|></img>\nOutput: <img><|image_2|></img>\n\nInput: <img><|image_3|></img>\nOutput:"
97
+ return generate_image(text, img1, img2, img3, height, width, img_guidance_scale, inference_steps, seed,
98
+ separate_cfg_infer, offload_model, use_input_image_size_as_output, max_input_image_size, randomize_seed, guidance_scale)
99
 
100
  description = """
101
  This is a Virtual Try-On Platform.