amaye15
commited on
Commit
·
adf5040
1
Parent(s):
a0761cf
point prompt
Browse files- app.py +17 -29
- requirments.txt +2 -0
app.py
CHANGED
|
@@ -1,34 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
(
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 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
|
| 34 |
-
|
|
|
|
| 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
|
| 22 |
+
demo.launch()
|
requirments.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
gradio_image_prompter
|