Potre1qw commited on
Commit
d5034e9
·
verified ·
1 Parent(s): 4cb92fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -3
app.py CHANGED
@@ -84,7 +84,7 @@ def check_server_ready(port):
84
 
85
 
86
 
87
- @spaces.GPU(duration=170)
88
  def generate_image(prompt, image):
89
  prefix_filename = str(random.randint(0, 999999))
90
  prompt = prompt.replace('ComfyUI', prefix_filename)
@@ -143,10 +143,94 @@ def generate_image(prompt, image):
143
 
144
 
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  if __name__ == "__main__":
147
- demo = gr.Interface(fn=generate_image, inputs=[
148
  "text",
149
- gr.Image(image_mode='RGBA', type="numpy")
 
150
  ],
151
  outputs=[
152
  gr.Image(type="numpy", image_mode='RGBA')
 
84
 
85
 
86
 
87
+
88
  def generate_image(prompt, image):
89
  prefix_filename = str(random.randint(0, 999999))
90
  prompt = prompt.replace('ComfyUI', prefix_filename)
 
143
 
144
 
145
 
146
+ @spaces.GPU(duration=50)
147
+ def generate_image_50(prompt, image):
148
+ return generate_image(prompt, image)
149
+
150
+ @spaces.GPU(duration=70)
151
+ def generate_image_70(prompt, image):
152
+ return generate_image(prompt, image)
153
+
154
+ @spaces.GPU(duration=90)
155
+ def generate_image_90(prompt, image):
156
+ return generate_image(prompt, image)
157
+
158
+ @spaces.GPU(duration=110)
159
+ def generate_image_110(prompt, image):
160
+ return generate_image(prompt, image)
161
+
162
+ @spaces.GPU(duration=130)
163
+ def generate_image_130(prompt, image):
164
+ return generate_image(prompt, image)
165
+
166
+ @spaces.GPU(duration=150)
167
+ def generate_image_150(prompt, image):
168
+ return generate_image(prompt, image)
169
+
170
+ @spaces.GPU(duration=170)
171
+ def generate_image_170(prompt, image):
172
+ return generate_image(prompt, image)
173
+
174
+ @spaces.GPU(duration=190)
175
+ def generate_image_190(prompt, image):
176
+ return generate_image(prompt, image)
177
+
178
+ @spaces.GPU(duration=200)
179
+ def generate_image_200(prompt, image):
180
+ return generate_image(prompt, image)
181
+
182
+ @spaces.GPU(duration=210)
183
+ def generate_image_210(prompt, image):
184
+ return generate_image(prompt, image)
185
+
186
+ @spaces.GPU(duration=220)
187
+ def generate_image_220(prompt, image):
188
+ return generate_image(prompt, image)
189
+
190
+ @spaces.GPU(duration=230)
191
+ def generate_image_230(prompt, image):
192
+ return generate_image(prompt, image)
193
+
194
+ @spaces.GPU(duration=240)
195
+ def generate_image_240(prompt, image):
196
+ return generate_image(prompt, image)
197
+
198
+
199
+ def generate_image_wrapper(prompt, image, duration):
200
+ if duration == "50":
201
+ return generate_image_50(prompt, image)
202
+ elif duration == "70":
203
+ return generate_image_70(prompt, image)
204
+ elif duration == "90":
205
+ return generate_image_90(prompt, image)
206
+ elif duration == "110":
207
+ return generate_image_110(prompt, image)
208
+ elif duration == "130":
209
+ return generate_image_130(prompt, image)
210
+ elif duration == "150":
211
+ return generate_image_150(prompt, image)
212
+ elif duration == "170":
213
+ return generate_image_170(prompt, image)
214
+ elif duration == "190":
215
+ return generate_image_190(prompt, image)
216
+ elif duration == "200":
217
+ return generate_image_200(prompt, image)
218
+ elif duration == "210":
219
+ return generate_image_210(prompt, image)
220
+ elif duration == "220":
221
+ return generate_image_220(prompt, image)
222
+ elif duration == "230":
223
+ return generate_image_230(prompt, image)
224
+ elif duration == "240":
225
+ return generate_image_240(prompt, image)
226
+ else:
227
+ return generate_image_170(prompt, image)
228
+
229
  if __name__ == "__main__":
230
+ demo = gr.Interface(fn=generate_image_wrapper, inputs=[
231
  "text",
232
+ gr.Image(image_mode='RGBA', type="numpy"),
233
+ "text"
234
  ],
235
  outputs=[
236
  gr.Image(type="numpy", image_mode='RGBA')