File size: 576 Bytes
a4110e1
 
 
 
 
 
 
 
 
 
 
 
 
33bf146
a4110e1
 
33bf146
a4110e1
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import numpy as np
from PIL import Image

def save_sketch(image):
    if image is None:
        return "No image drawn!"
    
    # Convert numpy array to PIL Image and save
    img = Image.fromarray(image.astype("uint8"))
    img.save("sketch.png")
    return "Sketch saved successfully!"

# Create Gradio Sketchpad (no `shape` argument needed)
iface = gr.Interface(
    fn=save_sketch,
    inputs=gr.Sketchpad(),
    outputs="text",
    title="Basic Drawing Canvas",
    description="Draw something and click submit to save the image."
)

iface.launch()