KurtLin commited on
Commit
2e39b8b
·
1 Parent(s): 11f87cc

Initial Commit

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +35 -0
  2. app.py +1 -2
.ipynb_checkpoints/app-checkpoint.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import cv2
4
+ # from segment_anything import sam_model_registry, SamPredictor
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")
14
+ with gr.Tabs():
15
+ with gr.TabItem("Select your image"):
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)
app.py CHANGED
@@ -1,8 +1,7 @@
1
  import numpy as np
2
- import torch
3
  import matplotlib.pyplot as plt
4
  import cv2
5
- from segment_anything import sam_model_registry, SamPredictor
6
  from preprocess import show_mask, show_points, show_box
7
  import gradio as gr
8
 
 
1
  import numpy as np
 
2
  import matplotlib.pyplot as plt
3
  import cv2
4
+ # from segment_anything import sam_model_registry, SamPredictor
5
  from preprocess import show_mask, show_points, show_box
6
  import gradio as gr
7