Spaces:
Running on Zero
Running on Zero
Commit ·
7d916cf
1
Parent(s): c10597c
Update app
Browse files
app.py
CHANGED
|
@@ -64,10 +64,11 @@ def preprocess_video(path, result_folder, padding=20):
|
|
| 64 |
for k in range(len(vr)):
|
| 65 |
all_frames.append(vr[k].asnumpy())
|
| 66 |
all_frames = np.asarray(all_frames)
|
|
|
|
| 67 |
|
| 68 |
# Load YOLOv5 model (pre-trained on COCO dataset)
|
| 69 |
yolo_model = YOLO("yolov9c.pt")
|
| 70 |
-
|
| 71 |
|
| 72 |
if frame_count < 25:
|
| 73 |
msg = "Not enough frames to process! Please give a longer video as input"
|
|
@@ -76,7 +77,7 @@ def preprocess_video(path, result_folder, padding=20):
|
|
| 76 |
person_videos = {}
|
| 77 |
person_tracks = {}
|
| 78 |
|
| 79 |
-
for frame_idx in range(frame_count):
|
| 80 |
|
| 81 |
frame = all_frames[frame_idx]
|
| 82 |
|
|
@@ -124,6 +125,8 @@ def preprocess_video(path, result_folder, padding=20):
|
|
| 124 |
msg = "Oops! Could not load the audio file. Please check the input video and try again."
|
| 125 |
return None, None, None, msg
|
| 126 |
|
|
|
|
|
|
|
| 127 |
# For the person detected, crop the frame based on the bounding box
|
| 128 |
if len(person_videos[0]) > frame_count-10:
|
| 129 |
crop_filename = os.path.join(result_folder, "preprocessed_video.avi")
|
|
|
|
| 64 |
for k in range(len(vr)):
|
| 65 |
all_frames.append(vr[k].asnumpy())
|
| 66 |
all_frames = np.asarray(all_frames)
|
| 67 |
+
print("Extracted the frames for pre-processing")
|
| 68 |
|
| 69 |
# Load YOLOv5 model (pre-trained on COCO dataset)
|
| 70 |
yolo_model = YOLO("yolov9c.pt")
|
| 71 |
+
print("Loaded the YOLO model")
|
| 72 |
|
| 73 |
if frame_count < 25:
|
| 74 |
msg = "Not enough frames to process! Please give a longer video as input"
|
|
|
|
| 77 |
person_videos = {}
|
| 78 |
person_tracks = {}
|
| 79 |
|
| 80 |
+
for frame_idx in tqdm(range(frame_count)):
|
| 81 |
|
| 82 |
frame = all_frames[frame_idx]
|
| 83 |
|
|
|
|
| 125 |
msg = "Oops! Could not load the audio file. Please check the input video and try again."
|
| 126 |
return None, None, None, msg
|
| 127 |
|
| 128 |
+
print("Extracted the audio from the video")
|
| 129 |
+
|
| 130 |
# For the person detected, crop the frame based on the bounding box
|
| 131 |
if len(person_videos[0]) > frame_count-10:
|
| 132 |
crop_filename = os.path.join(result_folder, "preprocessed_video.avi")
|