Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -74,7 +74,7 @@ def check_server_ready(port):
|
|
74 |
except requests.RequestException:
|
75 |
return False
|
76 |
|
77 |
-
|
78 |
def generate_image(prompt, image):
|
79 |
prefix_filename = str(random.randint(0, 999999))
|
80 |
try:
|
@@ -133,12 +133,98 @@ def generate_image(prompt, image):
|
|
133 |
logger.debug("process.kill()")
|
134 |
process.kill()
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
if __name__ == "__main__":
|
137 |
demo = gr.Interface(
|
138 |
-
fn=
|
139 |
inputs=[
|
140 |
"text",
|
141 |
-
gr.Image(image_mode='RGBA', type="numpy")
|
|
|
142 |
],
|
143 |
outputs=[gr.Image(type="numpy", image_mode='RGBA')],
|
144 |
title="Image Upscaler",
|
|
|
74 |
except requests.RequestException:
|
75 |
return False
|
76 |
|
77 |
+
|
78 |
def generate_image(prompt, image):
|
79 |
prefix_filename = str(random.randint(0, 999999))
|
80 |
try:
|
|
|
133 |
logger.debug("process.kill()")
|
134 |
process.kill()
|
135 |
|
136 |
+
|
137 |
+
|
138 |
+
@spaces.GPU(duration=50)
|
139 |
+
def generate_image_50(prompt, image):
|
140 |
+
return generate_image(prompt, image)
|
141 |
+
|
142 |
+
@spaces.GPU(duration=70)
|
143 |
+
def generate_image_70(prompt, image):
|
144 |
+
return generate_image(prompt, image)
|
145 |
+
|
146 |
+
@spaces.GPU(duration=90)
|
147 |
+
def generate_image_90(prompt, image):
|
148 |
+
return generate_image(prompt, image)
|
149 |
+
|
150 |
+
@spaces.GPU(duration=110)
|
151 |
+
def generate_image_110(prompt, image):
|
152 |
+
return generate_image(prompt, image)
|
153 |
+
|
154 |
+
@spaces.GPU(duration=130)
|
155 |
+
def generate_image_130(prompt, image):
|
156 |
+
return generate_image(prompt, image)
|
157 |
+
|
158 |
+
@spaces.GPU(duration=150)
|
159 |
+
def generate_image_150(prompt, image):
|
160 |
+
return generate_image(prompt, image)
|
161 |
+
|
162 |
+
@spaces.GPU(duration=170)
|
163 |
+
def generate_image_170(prompt, image):
|
164 |
+
return generate_image(prompt, image)
|
165 |
+
|
166 |
+
@spaces.GPU(duration=190)
|
167 |
+
def generate_image_190(prompt, image):
|
168 |
+
return generate_image(prompt, image)
|
169 |
+
|
170 |
+
@spaces.GPU(duration=200)
|
171 |
+
def generate_image_200(prompt, image):
|
172 |
+
return generate_image(prompt, image)
|
173 |
+
|
174 |
+
@spaces.GPU(duration=210)
|
175 |
+
def generate_image_210(prompt, image):
|
176 |
+
return generate_image(prompt, image)
|
177 |
+
|
178 |
+
@spaces.GPU(duration=220)
|
179 |
+
def generate_image_220(prompt, image):
|
180 |
+
return generate_image(prompt, image)
|
181 |
+
|
182 |
+
@spaces.GPU(duration=230)
|
183 |
+
def generate_image_230(prompt, image):
|
184 |
+
return generate_image(prompt, image)
|
185 |
+
|
186 |
+
@spaces.GPU(duration=240)
|
187 |
+
def generate_image_240(prompt, image):
|
188 |
+
return generate_image(prompt, image)
|
189 |
+
|
190 |
+
|
191 |
+
def generate_image_wrapper(prompt, image, duration):
|
192 |
+
if duration == "50":
|
193 |
+
return generate_image_50(prompt, image)
|
194 |
+
elif duration == "70":
|
195 |
+
return generate_image_70(prompt, image)
|
196 |
+
elif duration == "90":
|
197 |
+
return generate_image_90(prompt, image)
|
198 |
+
elif duration == "110":
|
199 |
+
return generate_image_110(prompt, image)
|
200 |
+
elif duration == "130":
|
201 |
+
return generate_image_130(prompt, image)
|
202 |
+
elif duration == "150":
|
203 |
+
return generate_image_150(prompt, image)
|
204 |
+
elif duration == "170":
|
205 |
+
return generate_image_170(prompt, image)
|
206 |
+
elif duration == "190":
|
207 |
+
return generate_image_190(prompt, image)
|
208 |
+
elif duration == "200":
|
209 |
+
return generate_image_200(prompt, image)
|
210 |
+
elif duration == "210":
|
211 |
+
return generate_image_210(prompt, image)
|
212 |
+
elif duration == "220":
|
213 |
+
return generate_image_220(prompt, image)
|
214 |
+
elif duration == "230":
|
215 |
+
return generate_image_230(prompt, image)
|
216 |
+
elif duration == "240":
|
217 |
+
return generate_image_240(prompt, image)
|
218 |
+
else:
|
219 |
+
return generate_image_170(prompt, image)
|
220 |
+
|
221 |
if __name__ == "__main__":
|
222 |
demo = gr.Interface(
|
223 |
+
fn=generate_image_wrapper,
|
224 |
inputs=[
|
225 |
"text",
|
226 |
+
gr.Image(image_mode='RGBA', type="numpy"),
|
227 |
+
"text"
|
228 |
],
|
229 |
outputs=[gr.Image(type="numpy", image_mode='RGBA')],
|
230 |
title="Image Upscaler",
|