Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
-
from PIL import Image
|
3 |
-
import numpy as np
|
4 |
-
import io
|
5 |
|
6 |
def display_sketch(sketch):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
return
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
output_image = gr.Image(label="Your Sketch")
|
17 |
|
18 |
-
|
|
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
def display_sketch(sketch):
|
4 |
+
import numpy as np
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
image_data = sketch["image"]
|
8 |
+
img = Image.fromarray(np.uint8(image_data))
|
9 |
+
return img
|
10 |
|
11 |
+
# Define the sketchpad component
|
12 |
+
sketchpad = gr.Sketchpad(label="Draw Something")
|
|
|
13 |
|
14 |
+
# Define the image component to display the sketch
|
15 |
+
output_image = gr.Image(label="Your Sketch")
|
16 |
|
17 |
+
# Create the interface
|
18 |
+
demo = gr.Interface(
|
19 |
+
fn=display_sketch,
|
20 |
+
inputs=sketchpad,
|
21 |
+
outputs=output_image,
|
22 |
+
live=True
|
23 |
+
)
|
24 |
+
|
25 |
+
# Launch the app
|
26 |
demo.launch()
|