Spaces:
Build error
Build error
Commit
·
9fdc17b
1
Parent(s):
d5404fe
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
|
|
|
|
|
|
3 |
|
4 |
|
5 |
def greet(input_img):
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
inp = gr.inputs.Image(
|
10 |
-
image_mode="L",
|
|
|
|
|
|
|
|
|
11 |
)
|
12 |
-
demo = gr.Interface(fn=greet, inputs=inp, outputs="image")
|
13 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from Sketch2ImgPipeline import Sketch2ImgPipeline
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
pipe = Sketch2ImgPipeline.from_pretrained("IzumiSatoshi/sketch2img-FashionMNIST")
|
6 |
|
7 |
|
8 |
def greet(input_img):
|
9 |
+
sketches = np.expand_dims(input_img, (0, 1))
|
10 |
+
sketches[sketches < 250] = 0
|
11 |
+
sketches[sketches >= 250] = 255
|
12 |
+
print(sketches.shape)
|
13 |
+
samples = pipe(sketches, num_inference_step=10)
|
14 |
+
out = samples[0][0]
|
15 |
+
print(out.shape)
|
16 |
+
return sketches[0][0], out
|
17 |
|
18 |
|
19 |
inp = gr.inputs.Image(
|
20 |
+
image_mode="L",
|
21 |
+
source="canvas",
|
22 |
+
shape=(28, 28),
|
23 |
+
invert_colors=True,
|
24 |
+
tool="select",
|
25 |
)
|
26 |
+
demo = gr.Interface(fn=greet, inputs=inp, outputs=["image", "image"])
|
27 |
demo.launch()
|