Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -246,11 +246,11 @@ def get_mask_sam_process(
|
|
246 |
# predictor.reset_state(inference_state) # if any previous tracking, reset
|
247 |
|
248 |
### HANDLING WORKING FRAME
|
249 |
-
new_working_frame = None
|
250 |
# Add new point
|
251 |
if working_frame is None:
|
252 |
ann_frame_idx = 0 # the frame index we interact with, 0 if it is the first frame
|
253 |
-
|
254 |
else:
|
255 |
# Use a regular expression to find the integer
|
256 |
match = re.search(r'frame_(\d+)', working_frame)
|
@@ -258,8 +258,8 @@ def get_mask_sam_process(
|
|
258 |
# Extract the integer from the match
|
259 |
frame_number = int(match.group(1))
|
260 |
ann_frame_idx = frame_number
|
261 |
-
|
262 |
-
print(f"NEW_WORKING_FRAME PATH: {
|
263 |
|
264 |
ann_obj_id = 1 # give a unique id to each object we interact with (it can be any integers)
|
265 |
|
@@ -288,7 +288,7 @@ def get_mask_sam_process(
|
|
288 |
plt.close()
|
289 |
torch.cuda.empty_cache()
|
290 |
|
291 |
-
return "output_first_frame.jpg", frame_names, inference_state
|
292 |
|
293 |
def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type, progress=gr.Progress(track_tqdm=True)):
|
294 |
#### PROPAGATION ####
|
@@ -510,6 +510,7 @@ with gr.Blocks() as demo:
|
|
510 |
output_result,
|
511 |
stored_frame_names,
|
512 |
stored_inference_state,
|
|
|
513 |
]
|
514 |
)
|
515 |
|
|
|
246 |
# predictor.reset_state(inference_state) # if any previous tracking, reset
|
247 |
|
248 |
### HANDLING WORKING FRAME
|
249 |
+
# new_working_frame = None
|
250 |
# Add new point
|
251 |
if working_frame is None:
|
252 |
ann_frame_idx = 0 # the frame index we interact with, 0 if it is the first frame
|
253 |
+
working_frame = "frame_0.jpg"
|
254 |
else:
|
255 |
# Use a regular expression to find the integer
|
256 |
match = re.search(r'frame_(\d+)', working_frame)
|
|
|
258 |
# Extract the integer from the match
|
259 |
frame_number = int(match.group(1))
|
260 |
ann_frame_idx = frame_number
|
261 |
+
|
262 |
+
print(f"NEW_WORKING_FRAME PATH: {working_frame}")
|
263 |
|
264 |
ann_obj_id = 1 # give a unique id to each object we interact with (it can be any integers)
|
265 |
|
|
|
288 |
plt.close()
|
289 |
torch.cuda.empty_cache()
|
290 |
|
291 |
+
return "output_first_frame.jpg", frame_names, inference_state, gr.update(value=working_frame, visible=True)
|
292 |
|
293 |
def propagate_to_all(video_in, checkpoint, stored_inference_state, stored_frame_names, video_frames_dir, vis_frame_type, progress=gr.Progress(track_tqdm=True)):
|
294 |
#### PROPAGATION ####
|
|
|
510 |
output_result,
|
511 |
stored_frame_names,
|
512 |
stored_inference_state,
|
513 |
+
working_frame,
|
514 |
]
|
515 |
)
|
516 |
|