|
import gradio as gr |
|
from PIL import Image, ImageDraw |
|
|
|
|
|
|
|
def mark_point(image, x, y): |
|
|
|
img = Image.fromarray(image) |
|
|
|
|
|
draw = ImageDraw.Draw(img) |
|
radius = 5 |
|
draw.ellipse( |
|
(x - radius, y - radius, x + radius, y + radius), fill="red", outline="red" |
|
) |
|
|
|
return img |
|
|
|
|
|
|
|
iface = gr.Interface( |
|
fn=mark_point, |
|
inputs=[ |
|
gr.Image(type="numpy", interactive=True), |
|
gr.Number(), |
|
gr.Number(), |
|
], |
|
outputs="image", |
|
title="Image Point Marker", |
|
description="Upload an image, click on it, and see the point marked.", |
|
) |
|
|
|
|
|
iface.launch() |
|
|