File size: 932 Bytes
f3004ad
85c140a
f3004ad
 
85c140a
99929dc
 
85c140a
 
 
 
 
99929dc
85c140a
 
 
 
 
f3004ad
 
63d8dec
 
85c140a
99929dc
 
 
85c140a
 
 
63d8dec
 
 
 
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
import gradio as gr
from PIL import Image, ImageDraw


# Define a function that marks the clicked point on the image
def mark_point(image, xy):
    # Convert the Gradio image (which is a numpy array) to a PIL Image
    img = Image.fromarray(image)

    # Draw a red circle at the clicked point
    draw = ImageDraw.Draw(img)
    radius = 5
    x, y = xy
    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", tool="select"
    ),  # Image input with the select tool enabled
    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()