Jiecong Lin
commited on
Commit
·
0c1b085
1
Parent(s):
a0a2cbe
save to tmp
Browse files
app.py
CHANGED
|
@@ -49,9 +49,9 @@ def clean(Seg_Tracker):
|
|
| 49 |
|
| 50 |
def get_meta_from_video(Seg_Tracker, input_video, scale_slider, checkpoint):
|
| 51 |
|
| 52 |
-
output_dir = 'output_frames'
|
| 53 |
-
output_masks_dir = 'output_masks'
|
| 54 |
-
output_combined_dir = 'output_combined'
|
| 55 |
clear_folder(output_dir)
|
| 56 |
clear_folder(output_masks_dir)
|
| 57 |
clear_folder(output_combined_dir)
|
|
@@ -116,7 +116,7 @@ def mask2bbox(mask):
|
|
| 116 |
|
| 117 |
def sam_stroke(Seg_Tracker, drawing_board, last_draw, frame_num, ann_obj_id):
|
| 118 |
predictor, inference_state, image_predictor = Seg_Tracker
|
| 119 |
-
image_path = f'output_frames/{frame_num:07d}.jpg'
|
| 120 |
image = cv2.imread(image_path)
|
| 121 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 122 |
display_image = drawing_board["image"]
|
|
@@ -180,7 +180,7 @@ def sam_click(Seg_Tracker, frame_num, point_mode, click_stack, ann_obj_id, evt:
|
|
| 180 |
labels=labels_dict[ann_frame_idx][ann_obj_id],
|
| 181 |
)
|
| 182 |
|
| 183 |
-
image_path = f'output_frames/{ann_frame_idx:07d}.jpg'
|
| 184 |
image = cv2.imread(image_path)
|
| 185 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 186 |
|
|
@@ -232,8 +232,8 @@ def show_mask(mask, image=None, obj_id=None):
|
|
| 232 |
return mask_image
|
| 233 |
|
| 234 |
def show_res_by_slider(frame_per, click_stack):
|
| 235 |
-
image_path = 'output_frames'
|
| 236 |
-
output_combined_dir = 'output_combined'
|
| 237 |
|
| 238 |
combined_frames = sorted([os.path.join(output_combined_dir, img_name) for img_name in os.listdir(output_combined_dir)])
|
| 239 |
if combined_frames:
|
|
@@ -272,11 +272,11 @@ def zip_folder(folder_path, output_zip_path):
|
|
| 272 |
zipf.write(file_path, os.path.relpath(file_path, folder_path))
|
| 273 |
|
| 274 |
def tracking_objects(Seg_Tracker, frame_num, input_video):
|
| 275 |
-
output_dir = 'output_frames'
|
| 276 |
-
output_masks_dir = 'output_masks'
|
| 277 |
-
output_combined_dir = 'output_combined'
|
| 278 |
-
output_video_path = 'output_video.mp4'
|
| 279 |
-
output_zip_path = 'output_masks.zip'
|
| 280 |
clear_folder(output_masks_dir)
|
| 281 |
clear_folder(output_combined_dir)
|
| 282 |
if os.path.exists(output_video_path):
|
|
|
|
| 49 |
|
| 50 |
def get_meta_from_video(Seg_Tracker, input_video, scale_slider, checkpoint):
|
| 51 |
|
| 52 |
+
output_dir = '/tmp/output_frames'
|
| 53 |
+
output_masks_dir = '/tmp/output_masks'
|
| 54 |
+
output_combined_dir = '/tmp/output_combined'
|
| 55 |
clear_folder(output_dir)
|
| 56 |
clear_folder(output_masks_dir)
|
| 57 |
clear_folder(output_combined_dir)
|
|
|
|
| 116 |
|
| 117 |
def sam_stroke(Seg_Tracker, drawing_board, last_draw, frame_num, ann_obj_id):
|
| 118 |
predictor, inference_state, image_predictor = Seg_Tracker
|
| 119 |
+
image_path = f'/tmp/output_frames/{frame_num:07d}.jpg'
|
| 120 |
image = cv2.imread(image_path)
|
| 121 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 122 |
display_image = drawing_board["image"]
|
|
|
|
| 180 |
labels=labels_dict[ann_frame_idx][ann_obj_id],
|
| 181 |
)
|
| 182 |
|
| 183 |
+
image_path = f'/tmp/output_frames/{ann_frame_idx:07d}.jpg'
|
| 184 |
image = cv2.imread(image_path)
|
| 185 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 186 |
|
|
|
|
| 232 |
return mask_image
|
| 233 |
|
| 234 |
def show_res_by_slider(frame_per, click_stack):
|
| 235 |
+
image_path = '/tmp/output_frames'
|
| 236 |
+
output_combined_dir = '/tmp/output_combined'
|
| 237 |
|
| 238 |
combined_frames = sorted([os.path.join(output_combined_dir, img_name) for img_name in os.listdir(output_combined_dir)])
|
| 239 |
if combined_frames:
|
|
|
|
| 272 |
zipf.write(file_path, os.path.relpath(file_path, folder_path))
|
| 273 |
|
| 274 |
def tracking_objects(Seg_Tracker, frame_num, input_video):
|
| 275 |
+
output_dir = '/tmp/output_frames'
|
| 276 |
+
output_masks_dir = '/tmp/output_masks'
|
| 277 |
+
output_combined_dir = '/tmp/output_combined'
|
| 278 |
+
output_video_path = '/tmp/output_video.mp4'
|
| 279 |
+
output_zip_path = '/tmp/output_masks.zip'
|
| 280 |
clear_folder(output_masks_dir)
|
| 281 |
clear_folder(output_combined_dir)
|
| 282 |
if os.path.exists(output_video_path):
|