KurtLin commited on
Commit
b9d077d
·
1 Parent(s): eac6fdd

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -5,9 +5,11 @@ import cv2
5
  from preprocess import show_mask, show_points, show_box
6
  import gradio as gr
7
 
8
- def get_coord(image):
9
- return coord
10
-
 
 
11
  my_app = gr.Blocks()
12
  with my_app:
13
  gr.Markdown("Segment Anything Testing")
@@ -16,20 +18,19 @@ with my_app:
16
  with gr.Row():
17
  with gr.Column():
18
  img_source = gr.Image(label="Please select picture.", value='./images/truck.jpg', shape=(768, 768))
19
-
20
- set_point = gr.Button(label="Set Point")
21
  with gr.Column():
22
  # img_output = gr.Image(label="Output Mask")
23
  coords = gr.Label(label="Image Coordinate.")
24
 
25
- set_point.click(
26
- img_source.select(get_coord),
27
- [
28
- img_source
29
- ],
30
- [
31
- coords
32
- ]
33
- )
 
34
 
35
  my_app.launch(debug=True)
 
5
  from preprocess import show_mask, show_points, show_box
6
  import gradio as gr
7
 
8
+ def get_select_coords(evt: gr.SelectData):
9
+ position = (evt.index[0], evt.index[1])
10
+ img_path = images[0]
11
+ return img_path, position
12
+
13
  my_app = gr.Blocks()
14
  with my_app:
15
  gr.Markdown("Segment Anything Testing")
 
18
  with gr.Row():
19
  with gr.Column():
20
  img_source = gr.Image(label="Please select picture.", value='./images/truck.jpg', shape=(768, 768))
 
 
21
  with gr.Column():
22
  # img_output = gr.Image(label="Output Mask")
23
  coords = gr.Label(label="Image Coordinate.")
24
 
25
+ input_img.select(get_select_coords, [], [img_source, coords])
26
+ # set_point.click(
27
+ # img_source.select(get_coord),
28
+ # [
29
+ # img_source
30
+ # ],
31
+ # [
32
+ # coords
33
+ # ]
34
+ # )
35
 
36
  my_app.launch(debug=True)