mrm8488 commited on
Commit
90da81e
β€’
1 Parent(s): 0ef1b73

Initial commit

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +37 -0
  3. requirements.txt +4 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .devcontainer
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import DDPMPipeline
2
+ import gradio as gr
3
+
4
+
5
+
6
+ models = [
7
+ {'type': 'pokemon', 'res': 64, 'id': 'mrm8488/ddpm-ema-pokemon-64'},
8
+ {'type': 'flowers', 'res': 64, 'id': 'mrm8488/ddpm-ema-flower-64'},
9
+ {'type': 'anime_faces', 'res': 128, 'id': 'mrm8488/mrm8488/ddpm-ema-anime-256'},
10
+ {'type': 'butterflies', 'res': 128, 'id': 'mrm8488/ddpm-ema-butterflies-128'},
11
+ {'type': 'human_faces', 'res': 256, 'id': 'fusing/ddpm-celeba-hq'}
12
+ ]
13
+
14
+ for model in models:
15
+ pipeline = DDPMPipeline.from_pretrained(model['id'])
16
+ pipeline.save_pretrained(model['id'])
17
+
18
+ def predict(type):
19
+ model_id = None
20
+ for model in models:
21
+ if model['type'] == type:
22
+ model_id = model['id']
23
+ break
24
+ # load model and scheduler
25
+ pipeline = DDPMPipeline.from_pretrained(model_id)
26
+
27
+ # run pipeline in inference
28
+ image = pipeline()["sample"]
29
+
30
+ return image[0]
31
+
32
+ gr.Interface(
33
+ predict,
34
+ inputs=[gr.components.Dropdown(choices = [model['type'] for model in models], label='Models')
35
+ ],
36
+ outputs=["image"]
37
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ gradio
3
+ diffusers
4
+ Pillow