amaye15 commited on
Commit
a4d9321
·
1 Parent(s): 99929dc

point prompt

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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, xy):
7
- # Convert the Gradio image (which is a numpy array) 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
- 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=gr.Image(
25
- type="numpy", tool="select"
26
- ), # Image input with the select tool enabled
 
 
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.",