amaye15
commited on
Commit
•
7e76bff
1
Parent(s):
9afc623
rollback
Browse files
app.py
CHANGED
@@ -1,38 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from gradio_image_prompter import ImagePrompter
|
3 |
-
from PIL import Image, ImageDraw
|
4 |
-
|
5 |
-
|
6 |
-
# Function to draw points on the image
|
7 |
-
def draw_points_on_image(prompts):
|
8 |
-
image = Image.fromarray(prompts["image"]) # Convert numpy array to PIL Image
|
9 |
-
points = prompts["points"] # Get the list of points
|
10 |
-
|
11 |
-
draw = ImageDraw.Draw(image)
|
12 |
-
radius = 5 # Radius of the circle to draw
|
13 |
-
|
14 |
-
# Draw each point on the image
|
15 |
-
for point in points:
|
16 |
-
x, y = point
|
17 |
-
draw.ellipse(
|
18 |
-
(x - radius, y - radius, x + radius, y + radius), fill="red", outline="red"
|
19 |
-
)
|
20 |
-
|
21 |
-
return image, points
|
22 |
-
|
23 |
|
24 |
# Define the Gradio interface
|
25 |
demo = gr.Interface(
|
26 |
-
fn=
|
|
|
|
|
|
|
27 |
inputs=ImagePrompter(
|
28 |
show_label=False
|
29 |
), # ImagePrompter for image input and point selection
|
30 |
outputs=[
|
31 |
gr.Image(show_label=False),
|
32 |
gr.Dataframe(label="Points"),
|
33 |
-
], # Outputs: Image
|
34 |
-
title="Image Point
|
35 |
-
description="Upload an image, click on it, and
|
36 |
)
|
37 |
|
38 |
# Launch the Gradio app
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_image_prompter import ImagePrompter
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Define the Gradio interface
|
5 |
demo = gr.Interface(
|
6 |
+
fn=lambda prompts: (
|
7 |
+
prompts["image"],
|
8 |
+
prompts["points"],
|
9 |
+
), # Extract image and points from the ImagePrompter
|
10 |
inputs=ImagePrompter(
|
11 |
show_label=False
|
12 |
), # ImagePrompter for image input and point selection
|
13 |
outputs=[
|
14 |
gr.Image(show_label=False),
|
15 |
gr.Dataframe(label="Points"),
|
16 |
+
], # Outputs: Image and DataFrame of points
|
17 |
+
title="Image Point Collector",
|
18 |
+
description="Upload an image, click on it, and get the coordinates of the clicked points.",
|
19 |
)
|
20 |
|
21 |
# Launch the Gradio app
|