Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from sam2.sam2_image_predictor import SAM2ImagePredictor
|
|
| 12 |
def preprocess_image(image):
|
| 13 |
return image, gr.State([]), gr.State([]), image
|
| 14 |
|
| 15 |
-
def get_point(point_type, tracking_points, trackings_input_label, first_frame_path, evt):
|
| 16 |
print(f"You selected {evt.value} at {evt.index} from {evt.target}")
|
| 17 |
|
| 18 |
tracking_points.value.append(evt.index)
|
|
@@ -177,6 +177,14 @@ with gr.Blocks() as demo:
|
|
| 177 |
trackings_input_label = gr.State([])
|
| 178 |
with gr.Column():
|
| 179 |
gr.Markdown("# SAM2 Image Predictor")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
with gr.Row():
|
| 181 |
with gr.Column():
|
| 182 |
input_image = gr.Image(label="input image", interactive=False, type="filepath", visible=False)
|
|
|
|
| 12 |
def preprocess_image(image):
|
| 13 |
return image, gr.State([]), gr.State([]), image
|
| 14 |
|
| 15 |
+
def get_point(point_type, tracking_points, trackings_input_label, first_frame_path, evt: gr.SelectData):
|
| 16 |
print(f"You selected {evt.value} at {evt.index} from {evt.target}")
|
| 17 |
|
| 18 |
tracking_points.value.append(evt.index)
|
|
|
|
| 177 |
trackings_input_label = gr.State([])
|
| 178 |
with gr.Column():
|
| 179 |
gr.Markdown("# SAM2 Image Predictor")
|
| 180 |
+
gr.Markdown("This is a simple demo for image segmentation with SAM2.")
|
| 181 |
+
gr.Markdown("""Instructions:
|
| 182 |
+
|
| 183 |
+
1. Upload your image
|
| 184 |
+
2. With 'include' point type selected, Click on the object to mask
|
| 185 |
+
3. Switch to 'exclude' point type if you want to specify an area to avoid
|
| 186 |
+
4. Submit !
|
| 187 |
+
""")
|
| 188 |
with gr.Row():
|
| 189 |
with gr.Column():
|
| 190 |
input_image = gr.Image(label="input image", interactive=False, type="filepath", visible=False)
|