Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -40,6 +40,14 @@ np.random.seed(42)
|
|
40 |
colors = np.random.randint(0, 255, size=(len(model.names), 3), dtype=np.uint8)
|
41 |
|
42 |
def process_video(video_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
cap = cv2.VideoCapture(video_path)
|
44 |
|
45 |
if not cap.isOpened():
|
|
|
40 |
colors = np.random.randint(0, 255, size=(len(model.names), 3), dtype=np.uint8)
|
41 |
|
42 |
def process_video(video_path):
|
43 |
+
# Check if video_path is None or empty
|
44 |
+
if video_path is None or video_path == "":
|
45 |
+
return None
|
46 |
+
|
47 |
+
# Handle the case when Gradio passes a tuple (file, None)
|
48 |
+
if isinstance(video_path, tuple) and len(video_path) >= 1:
|
49 |
+
video_path = video_path[0]
|
50 |
+
|
51 |
cap = cv2.VideoCapture(video_path)
|
52 |
|
53 |
if not cap.isOpened():
|