Jangai commited on
Commit
ea1e865
·
verified ·
1 Parent(s): 8dad8dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -19
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 an image
7
- img = Image.fromarray(np.uint8(sketch))
8
- return img
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
- # Create the interface
17
- demo = gr.Interface(
18
- fn=display_sketch,
19
- inputs=sketchpad,
20
- outputs=output_image,
21
- live=True
22
- )
23
 
24
- # Launch the app
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()