File size: 930 Bytes
f3004ad
a0761cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63d8dec
 
 
a0761cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()