amaye15
commited on
Commit
·
85c140a
1
Parent(s):
0559e3c
make point
Browse files
app.py
CHANGED
@@ -1,19 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
-
from PIL import Image
|
3 |
|
4 |
|
5 |
-
# Define a function that
|
6 |
-
def
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
# Create the Gradio interface
|
11 |
iface = gr.Interface(
|
12 |
-
fn=
|
13 |
-
inputs=
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
)
|
18 |
|
19 |
# Launch the Gradio app
|
|
|
1 |
import gradio as gr
|
2 |
+
from PIL import Image, ImageDraw
|
3 |
|
4 |
|
5 |
+
# Define a function that marks the clicked point on the image
|
6 |
+
def mark_point(image, x, y):
|
7 |
+
# Convert the Gradio image to a PIL Image
|
8 |
+
img = Image.fromarray(image)
|
9 |
+
|
10 |
+
# Draw a red circle at the clicked point
|
11 |
+
draw = ImageDraw.Draw(img)
|
12 |
+
radius = 5
|
13 |
+
draw.ellipse(
|
14 |
+
(x - radius, y - radius, x + radius, y + radius), fill="red", outline="red"
|
15 |
+
)
|
16 |
+
|
17 |
+
return img
|
18 |
|
19 |
|
20 |
# Create the Gradio interface
|
21 |
iface = gr.Interface(
|
22 |
+
fn=mark_point, # The function that marks the point on the image
|
23 |
+
inputs=[
|
24 |
+
gr.Image(type="numpy", interactive=True),
|
25 |
+
gr.Number(),
|
26 |
+
gr.Number(),
|
27 |
+
], # Image input and coordinates
|
28 |
+
outputs="image", # The output will be an image with the point marked
|
29 |
+
title="Image Point Marker",
|
30 |
+
description="Upload an image, click on it, and see the point marked.",
|
31 |
)
|
32 |
|
33 |
# Launch the Gradio app
|