Spaces:
Build error
Build error
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,97 @@ 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 |
+
@spaces.GPU(duration=50)
|
| 138 |
+
def generate_image_50(prompt, image):
|
| 139 |
+
return generate_image(prompt, image)
|
| 140 |
+
|
| 141 |
+
@spaces.GPU(duration=70)
|
| 142 |
+
def generate_image_70(prompt, image):
|
| 143 |
+
return generate_image(prompt, image)
|
| 144 |
+
|
| 145 |
+
@spaces.GPU(duration=90)
|
| 146 |
+
def generate_image_90(prompt, image):
|
| 147 |
+
return generate_image(prompt, image)
|
| 148 |
+
|
| 149 |
+
@spaces.GPU(duration=110)
|
| 150 |
+
def generate_image_110(prompt, image):
|
| 151 |
+
return generate_image(prompt, image)
|
| 152 |
+
|
| 153 |
+
@spaces.GPU(duration=130)
|
| 154 |
+
def generate_image_130(prompt, image):
|
| 155 |
+
return generate_image(prompt, image)
|
| 156 |
+
|
| 157 |
+
@spaces.GPU(duration=150)
|
| 158 |
+
def generate_image_150(prompt, image):
|
| 159 |
+
return generate_image(prompt, image)
|
| 160 |
+
|
| 161 |
+
@spaces.GPU(duration=170)
|
| 162 |
+
def generate_image_170(prompt, image):
|
| 163 |
+
return generate_image(prompt, image)
|
| 164 |
+
|
| 165 |
+
@spaces.GPU(duration=190)
|
| 166 |
+
def generate_image_190(prompt, image):
|
| 167 |
+
return generate_image(prompt, image)
|
| 168 |
+
|
| 169 |
+
@spaces.GPU(duration=200)
|
| 170 |
+
def generate_image_200(prompt, image):
|
| 171 |
+
return generate_image(prompt, image)
|
| 172 |
+
|
| 173 |
+
@spaces.GPU(duration=210)
|
| 174 |
+
def generate_image_210(prompt, image):
|
| 175 |
+
return generate_image(prompt, image)
|
| 176 |
+
|
| 177 |
+
@spaces.GPU(duration=220)
|
| 178 |
+
def generate_image_220(prompt, image):
|
| 179 |
+
return generate_image(prompt, image)
|
| 180 |
+
|
| 181 |
+
@spaces.GPU(duration=230)
|
| 182 |
+
def generate_image_230(prompt, image):
|
| 183 |
+
return generate_image(prompt, image)
|
| 184 |
+
|
| 185 |
+
@spaces.GPU(duration=240)
|
| 186 |
+
def generate_image_240(prompt, image):
|
| 187 |
+
return generate_image(prompt, image)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def generate_image_wrapper(prompt, image, duration):
|
| 191 |
+
if duration == "50":
|
| 192 |
+
return generate_image_50(prompt, image)
|
| 193 |
+
elif duration == "70":
|
| 194 |
+
return generate_image_70(prompt, image)
|
| 195 |
+
elif duration == "90":
|
| 196 |
+
return generate_image_90(prompt, image)
|
| 197 |
+
elif duration == "110":
|
| 198 |
+
return generate_image_110(prompt, image)
|
| 199 |
+
elif duration == "130":
|
| 200 |
+
return generate_image_130(prompt, image)
|
| 201 |
+
elif duration == "150":
|
| 202 |
+
return generate_image_150(prompt, image)
|
| 203 |
+
elif duration == "170":
|
| 204 |
+
return generate_image_170(prompt, image)
|
| 205 |
+
elif duration == "190":
|
| 206 |
+
return generate_image_190(prompt, image)
|
| 207 |
+
elif duration == "200":
|
| 208 |
+
return generate_image_200(prompt, image)
|
| 209 |
+
elif duration == "210":
|
| 210 |
+
return generate_image_210(prompt, image)
|
| 211 |
+
elif duration == "220":
|
| 212 |
+
return generate_image_220(prompt, image)
|
| 213 |
+
elif duration == "230":
|
| 214 |
+
return generate_image_230(prompt, image)
|
| 215 |
+
elif duration == "240":
|
| 216 |
+
return generate_image_240(prompt, image)
|
| 217 |
+
else:
|
| 218 |
+
return generate_image_170(prompt, image)
|
| 219 |
+
|
| 220 |
if __name__ == "__main__":
|
| 221 |
demo = gr.Interface(
|
| 222 |
+
fn=generate_image_wrapper,
|
| 223 |
inputs=[
|
| 224 |
"text",
|
| 225 |
+
gr.Image(image_mode='RGBA', type="numpy"),
|
| 226 |
+
"text"
|
| 227 |
],
|
| 228 |
outputs=[gr.Image(type="numpy", image_mode='RGBA')],
|
| 229 |
title="Image Upscaler",
|