Spaces:
Paused
Paused
Update web-demos/hugging_face/app.py
Browse files- web-demos/hugging_face/app.py +14 -20
web-demos/hugging_face/app.py
CHANGED
@@ -78,7 +78,6 @@ def get_frames_from_video(video_input, video_state):
|
|
78 |
user_name = time.time()
|
79 |
status_ok = True
|
80 |
operation_log = [("[Must Do]", "Click image"), (": Video uploaded! Try to click the image shown in step2 to add masks.\n", None)]
|
81 |
-
|
82 |
try:
|
83 |
cap = cv2.VideoCapture(video_path)
|
84 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
@@ -90,29 +89,24 @@ def get_frames_from_video(video_input, video_state):
|
|
90 |
if ret == True:
|
91 |
original_h, original_w = frame.shape[:2]
|
92 |
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
else:
|
102 |
-
break
|
103 |
-
t = len(frames)
|
104 |
-
if t > 0:
|
105 |
-
print(f'Inp video shape: t_{t}, s_{original_h}x{original_w}')
|
106 |
else:
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
108 |
except (OSError, TypeError, ValueError, KeyError, SyntaxError) as e:
|
109 |
status_ok = False
|
110 |
print("read_frame_source:{} error. {}\n".format(video_path, str(e)))
|
111 |
-
|
112 |
-
if not frames:
|
113 |
-
raise ValueError("Не удалось извлечь кадры из видео. Проверьте файл.")
|
114 |
-
print("Загружено кадров:", len(frames))
|
115 |
-
print("Тип frames:", type(frames))
|
116 |
|
117 |
# initialize video_state
|
118 |
if frames[0].shape[0] > 720 or frames[0].shape[1] > 720:
|
|
|
78 |
user_name = time.time()
|
79 |
status_ok = True
|
80 |
operation_log = [("[Must Do]", "Click image"), (": Video uploaded! Try to click the image shown in step2 to add masks.\n", None)]
|
|
|
81 |
try:
|
82 |
cap = cv2.VideoCapture(video_path)
|
83 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
|
|
89 |
if ret == True:
|
90 |
original_h, original_w = frame.shape[:2]
|
91 |
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
92 |
+
status_ok = False
|
93 |
+
else:
|
94 |
+
while cap.isOpened():
|
95 |
+
ret, frame = cap.read()
|
96 |
+
if ret == True:
|
97 |
+
# resize input image
|
98 |
+
original_h, original_w = frame.shape[:2]
|
99 |
+
frames.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
|
|
|
|
|
|
|
|
|
|
|
100 |
else:
|
101 |
+
break
|
102 |
+
t = len(frames)
|
103 |
+
if t > 0:
|
104 |
+
print(f'Inp video shape: t_{t}, s_{original_h}x{original_w}')
|
105 |
+
else:
|
106 |
+
print(f'Inp video shape: t_{t}, no input video!!!')
|
107 |
except (OSError, TypeError, ValueError, KeyError, SyntaxError) as e:
|
108 |
status_ok = False
|
109 |
print("read_frame_source:{} error. {}\n".format(video_path, str(e)))
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
# initialize video_state
|
112 |
if frames[0].shape[0] > 720 or frames[0].shape[1] > 720:
|