amaye15
point prompt
a0761cf
raw
history blame
930 Bytes
import gradio as gr
from PIL import Image, ImageDraw
# Define a function that marks the clicked point on the image
def mark_point(image, x, y):
# Convert the Gradio image to a PIL Image
img = Image.fromarray(image)
# Draw a red circle at the clicked point
draw = ImageDraw.Draw(img)
radius = 5
draw.ellipse(
(x - radius, y - radius, x + radius, y + radius), fill="red", outline="red"
)
return img
# Create the Gradio interface
iface = gr.Interface(
fn=mark_point, # The function that marks the point on the image
inputs=[
gr.Image(type="numpy", interactive=True),
gr.Number(),
gr.Number(),
], # Image input and coordinates
outputs="image", # The output will be an image with the point marked
title="Image Point Marker",
description="Upload an image, click on it, and see the point marked.",
)
# Launch the Gradio app
iface.launch()