Spaces:
Build error
Build error
Commit
·
a11d2e7
1
Parent(s):
8cdf719
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
import numpy as np
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
out = samples[0][0]
|
| 15 |
-
print(out.shape)
|
| 16 |
-
return sketches[0][0], out
|
| 17 |
|
| 18 |
|
| 19 |
inp = gr.inputs.Image(
|
|
@@ -23,5 +24,5 @@ inp = gr.inputs.Image(
|
|
| 23 |
invert_colors=True,
|
| 24 |
tool="select",
|
| 25 |
)
|
| 26 |
-
demo = gr.Interface(fn=
|
| 27 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from pipeline_ddpm_sketch2img import DDPMSketch2ImgPipeline
|
| 3 |
import numpy as np
|
| 4 |
+
from diffusers import DDPMScheduler, DPMSolverMultistepScheduler, DDIMScheduler
|
| 5 |
+
from PIL import Image
|
| 6 |
|
| 7 |
+
model_path = "IzumiSatoshi/sketch2img-FashionMNIST"
|
| 8 |
+
pipe = DDPMSketch2ImgPipeline.from_pretrained(model_path).to("cpu")
|
| 9 |
+
pipe.scheduler = DDIMScheduler.from_pretrained(model_path, subfolder="scheduler")
|
| 10 |
|
| 11 |
|
| 12 |
+
def draw(sketch):
|
| 13 |
+
sketch[sketch < 250] = 0
|
| 14 |
+
sketch[sketch >= 250] = 255
|
| 15 |
+
sketch = Image.fromarray(sketch)
|
| 16 |
+
image = pipe(sketch, num_inference_step=50)
|
| 17 |
+
return sketch, image
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
inp = gr.inputs.Image(
|
|
|
|
| 24 |
invert_colors=True,
|
| 25 |
tool="select",
|
| 26 |
)
|
| 27 |
+
demo = gr.Interface(fn=draw, inputs=inp, outputs=["image", "image"])
|
| 28 |
demo.launch()
|