Spaces:
Runtime error
Runtime error
Update app
Browse files
app.py
CHANGED
|
@@ -3,38 +3,43 @@ import gradio as gr
|
|
| 3 |
from ui import title, description, examples
|
| 4 |
|
| 5 |
|
|
|
|
| 6 |
|
| 7 |
models = [
|
| 8 |
-
{'type': 'pokemon', 'res': 64, 'id': 'mrm8488/ddpm-ema-pokemon-64'},
|
| 9 |
-
{'type': 'flowers', 'res': 64, 'id': 'mrm8488/ddpm-ema-flower-64'},
|
| 10 |
-
{'type': 'anime_faces', 'res': 128, 'id': 'mrm8488/
|
| 11 |
-
{'type': 'butterflies', 'res': 128, 'id': 'mrm8488/ddpm-ema-butterflies-128'},
|
| 12 |
-
{'type': 'human_faces', 'res': 256, 'id': 'fusing/ddpm-celeba-hq'}
|
| 13 |
]
|
| 14 |
-
'''
|
| 15 |
for model in models:
|
| 16 |
pipeline = DDPMPipeline.from_pretrained(model['id'])
|
| 17 |
-
pipeline.save_pretrained(
|
| 18 |
-
''
|
|
|
|
|
|
|
| 19 |
def predict(type):
|
| 20 |
-
|
| 21 |
for model in models:
|
| 22 |
if model['type'] == type:
|
| 23 |
-
|
|
|
|
| 24 |
break
|
| 25 |
# load model and scheduler
|
| 26 |
-
pipeline = DDPMPipeline.from_pretrained(model_id)
|
| 27 |
|
| 28 |
-
# run pipeline in inference
|
| 29 |
image = pipeline()["sample"]
|
| 30 |
|
| 31 |
return image[0]
|
| 32 |
|
|
|
|
| 33 |
gr.Interface(
|
| 34 |
predict,
|
| 35 |
-
inputs=[gr.components.Dropdown(choices
|
| 36 |
-
|
| 37 |
-
outputs=["
|
|
|
|
| 38 |
title=title,
|
| 39 |
description=description
|
| 40 |
-
).launch()
|
|
|
|
| 3 |
from ui import title, description, examples
|
| 4 |
|
| 5 |
|
| 6 |
+
RES = None
|
| 7 |
|
| 8 |
models = [
|
| 9 |
+
{'type': 'pokemon', 'res': 64, 'id': 'mrm8488/ddpm-ema-pokemon-64'},
|
| 10 |
+
{'type': 'flowers', 'res': 64, 'id': 'mrm8488/ddpm-ema-flower-64'},
|
| 11 |
+
{'type': 'anime_faces', 'res': 128, 'id': 'mrm8488/ddpm-ema-anime-256'},
|
| 12 |
+
{'type': 'butterflies', 'res': 128, 'id': 'mrm8488/ddpm-ema-butterflies-128'},
|
| 13 |
+
{'type': 'human_faces', 'res': 256, 'id': 'fusing/ddpm-celeba-hq'}
|
| 14 |
]
|
|
|
|
| 15 |
for model in models:
|
| 16 |
pipeline = DDPMPipeline.from_pretrained(model['id'])
|
| 17 |
+
pipeline.save_pretrained('.')
|
| 18 |
+
model['pipeline'] = pipeline
|
| 19 |
+
|
| 20 |
+
|
| 21 |
def predict(type):
|
| 22 |
+
pipeline = None
|
| 23 |
for model in models:
|
| 24 |
if model['type'] == type:
|
| 25 |
+
pipeline = model['pipeline']
|
| 26 |
+
RES = model['res']
|
| 27 |
break
|
| 28 |
# load model and scheduler
|
| 29 |
+
#pipeline = DDPMPipeline.from_pretrained(model_id)
|
| 30 |
|
| 31 |
+
# run pipeline in inference
|
| 32 |
image = pipeline()["sample"]
|
| 33 |
|
| 34 |
return image[0]
|
| 35 |
|
| 36 |
+
|
| 37 |
gr.Interface(
|
| 38 |
predict,
|
| 39 |
+
inputs=[gr.components.Dropdown(choices=[model['type'] for model in models], label='Choose a model')
|
| 40 |
+
],
|
| 41 |
+
outputs=[gr.Image(shape=[RES, RES], type="pil",
|
| 42 |
+
elem_id="generated_image")],
|
| 43 |
title=title,
|
| 44 |
description=description
|
| 45 |
+
).launch()
|