amaye15
commited on
Commit
·
a4d9321
1
Parent(s):
99929dc
point prompt
Browse files
app.py
CHANGED
@@ -3,14 +3,13 @@ from PIL import Image, ImageDraw
|
|
3 |
|
4 |
|
5 |
# Define a function that marks the clicked point on the image
|
6 |
-
def mark_point(image,
|
7 |
-
# Convert the Gradio 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 |
-
x, y = xy
|
14 |
draw.ellipse(
|
15 |
(x - radius, y - radius, x + radius, y + radius), fill="red", outline="red"
|
16 |
)
|
@@ -21,9 +20,11 @@ def mark_point(image, xy):
|
|
21 |
# Create the Gradio interface
|
22 |
iface = gr.Interface(
|
23 |
fn=mark_point, # The function that marks the point on the image
|
24 |
-
inputs=
|
25 |
-
type="numpy",
|
26 |
-
|
|
|
|
|
27 |
outputs="image", # The output will be an image with the point marked
|
28 |
title="Image Point Marker",
|
29 |
description="Upload an image, click on it, and see the point marked.",
|
|
|
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 |
)
|
|
|
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.",
|