Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
-
from PIL import Image
|
3 |
import numpy as np
|
|
|
4 |
|
5 |
def display_sketch(sketch):
|
6 |
-
# Convert the sketch numpy array to
|
7 |
-
|
8 |
-
return
|
9 |
-
|
10 |
-
# Define the sketchpad component
|
11 |
-
sketchpad = gr.Sketchpad(label="Draw Something")
|
12 |
-
|
13 |
-
# Define the image component to display the sketch
|
14 |
-
output_image = gr.Image(label="Your Sketch")
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
outputs=output_image
|
21 |
-
live=True
|
22 |
-
)
|
23 |
|
24 |
-
|
25 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
|
5 |
def display_sketch(sketch):
|
6 |
+
# Convert the sketch (which is a numpy array) to a PIL image
|
7 |
+
image = Image.fromarray(sketch)
|
8 |
+
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
with gr.Blocks() as demo:
|
11 |
+
sketchpad = gr.Sketchpad(label="Draw Something", shape=(256, 256))
|
12 |
+
output_image = gr.Image(label="Your Sketch")
|
13 |
+
|
14 |
+
sketchpad.submit(display_sketch, inputs=sketchpad, outputs=output_image)
|
|
|
|
|
15 |
|
16 |
+
demo.launch()
|
|