Spaces:
Sleeping
Sleeping
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() | |