Spaces:
Configuration error
Configuration error
Commit
·
a794399
1
Parent(s):
10903f4
Update app
Browse files
app.py
CHANGED
|
@@ -56,6 +56,7 @@ print("Device: ", device)
|
|
| 56 |
holistic = mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
| 57 |
|
| 58 |
|
|
|
|
| 59 |
def bb_intersection_over_union(boxA, boxB):
|
| 60 |
xA = max(boxA[0], boxB[0])
|
| 61 |
yA = max(boxA[1], boxB[1])
|
|
@@ -316,6 +317,7 @@ def process_video_asd(file, sd_root, work_root, data_root, avi_dir, tmp_dir, wor
|
|
| 316 |
except:
|
| 317 |
msg = "Error in pre-processing the video, please check the input video and try again"
|
| 318 |
return msg
|
|
|
|
| 319 |
|
| 320 |
print("Detecting scenes in the video...")
|
| 321 |
try:
|
|
@@ -323,29 +325,22 @@ def process_video_asd(file, sd_root, work_root, data_root, avi_dir, tmp_dir, wor
|
|
| 323 |
except:
|
| 324 |
msg = "Error in detecting the scenes in the video, please check the input video and try again"
|
| 325 |
return msg
|
| 326 |
-
|
|
|
|
| 327 |
print("Tracking video...")
|
| 328 |
allscenes = []
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
allscenes.append(track_shot(faces[shot[0].frame_num:shot[1].frame_num]))
|
| 333 |
-
except:
|
| 334 |
-
msg = "Error in tracking people in the video, please check the input video and try again"
|
| 335 |
-
return msg
|
| 336 |
|
| 337 |
print("Cropping video...")
|
| 338 |
alltracks = []
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
alltracks.append(vidtracks)
|
| 346 |
-
except:
|
| 347 |
-
msg = "Error in cropping the video, please check the input video and try again"
|
| 348 |
-
return msg
|
| 349 |
|
| 350 |
savepath = os.path.join(work_dir, 'tracks.pckl')
|
| 351 |
|
|
@@ -361,6 +356,7 @@ def process_video_asd(file, sd_root, work_root, data_root, avi_dir, tmp_dir, wor
|
|
| 361 |
return "success"
|
| 362 |
|
| 363 |
|
|
|
|
| 364 |
@spaces.GPU(duration=140)
|
| 365 |
def preprocess_video(path, result_folder, apply_preprocess, padding=20):
|
| 366 |
|
|
@@ -1222,13 +1218,11 @@ def preprocess_asd(video_path, result_folder_input):
|
|
| 1222 |
crop_dir = os.path.join(data_dir, 'pycrop')
|
| 1223 |
frames_dir = os.path.join(data_dir, 'pyframes')
|
| 1224 |
|
| 1225 |
-
print("Pre-processing the input video...")
|
| 1226 |
status = process_video_asd(file, sd_root, work_root, data_root, avi_dir, tmp_dir, work_dir, crop_dir, frames_dir)
|
| 1227 |
-
|
| 1228 |
if status != "success":
|
| 1229 |
return status
|
| 1230 |
-
|
| 1231 |
-
|
| 1232 |
return "success"
|
| 1233 |
|
| 1234 |
def process_video_syncoffset(video_path, num_avg_frames, apply_preprocess):
|
|
|
|
| 56 |
holistic = mp_holistic.Holistic(min_detection_confidence=0.5, min_tracking_confidence=0.5)
|
| 57 |
|
| 58 |
|
| 59 |
+
|
| 60 |
def bb_intersection_over_union(boxA, boxB):
|
| 61 |
xA = max(boxA[0], boxB[0])
|
| 62 |
yA = max(boxA[1], boxB[1])
|
|
|
|
| 317 |
except:
|
| 318 |
msg = "Error in pre-processing the video, please check the input video and try again"
|
| 319 |
return msg
|
| 320 |
+
print("YOLO done")
|
| 321 |
|
| 322 |
print("Detecting scenes in the video...")
|
| 323 |
try:
|
|
|
|
| 325 |
except:
|
| 326 |
msg = "Error in detecting the scenes in the video, please check the input video and try again"
|
| 327 |
return msg
|
| 328 |
+
print("Scene detect done")
|
| 329 |
+
|
| 330 |
print("Tracking video...")
|
| 331 |
allscenes = []
|
| 332 |
+
for shot in scene:
|
| 333 |
+
if shot[1].frame_num - shot[0].frame_num >= min_track:
|
| 334 |
+
allscenes.append(track_shot(faces[shot[0].frame_num:shot[1].frame_num]))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
print("Cropping video...")
|
| 337 |
alltracks = []
|
| 338 |
+
for sc_num in range(len(allscenes)):
|
| 339 |
+
vidtracks = []
|
| 340 |
+
for ii, track in enumerate(allscenes[sc_num]):
|
| 341 |
+
os.makedirs(os.path.join(crop_dir, 'scene_'+str(sc_num)), exist_ok=True)
|
| 342 |
+
vidtracks.append(crop_video(avi_dir, tmp_dir, track, os.path.join(crop_dir, 'scene_'+str(sc_num), '%05d' % ii)))
|
| 343 |
+
alltracks.append(vidtracks)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
savepath = os.path.join(work_dir, 'tracks.pckl')
|
| 346 |
|
|
|
|
| 356 |
return "success"
|
| 357 |
|
| 358 |
|
| 359 |
+
|
| 360 |
@spaces.GPU(duration=140)
|
| 361 |
def preprocess_video(path, result_folder, apply_preprocess, padding=20):
|
| 362 |
|
|
|
|
| 1218 |
crop_dir = os.path.join(data_dir, 'pycrop')
|
| 1219 |
frames_dir = os.path.join(data_dir, 'pyframes')
|
| 1220 |
|
|
|
|
| 1221 |
status = process_video_asd(file, sd_root, work_root, data_root, avi_dir, tmp_dir, work_dir, crop_dir, frames_dir)
|
| 1222 |
+
print("Status ", status)
|
| 1223 |
if status != "success":
|
| 1224 |
return status
|
| 1225 |
+
|
|
|
|
| 1226 |
return "success"
|
| 1227 |
|
| 1228 |
def process_video_syncoffset(video_path, num_avg_frames, apply_preprocess):
|