Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,6 +40,10 @@ 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():
|
|
@@ -117,11 +121,9 @@ css = """
|
|
| 117 |
margin: 1.5rem 0;
|
| 118 |
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
| 119 |
}
|
| 120 |
-
|
| 121 |
.gradio-container {
|
| 122 |
background-color: #F5F7FA;
|
| 123 |
}
|
| 124 |
-
|
| 125 |
.tab-item {
|
| 126 |
background-color: white;
|
| 127 |
border-radius: 10px;
|
|
@@ -129,30 +131,25 @@ css = """
|
|
| 129 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 130 |
margin: 10px;
|
| 131 |
}
|
| 132 |
-
|
| 133 |
.button-row {
|
| 134 |
display: flex;
|
| 135 |
justify-content: space-around;
|
| 136 |
margin: 1rem 0;
|
| 137 |
}
|
| 138 |
-
|
| 139 |
#video-process-btn, #submit-btn {
|
| 140 |
background-color: #3498DB;
|
| 141 |
border: none;
|
| 142 |
}
|
| 143 |
-
|
| 144 |
#clear-btn {
|
| 145 |
background-color: #E74C3C;
|
| 146 |
border: none;
|
| 147 |
}
|
| 148 |
-
|
| 149 |
.output-container {
|
| 150 |
margin-top: 1.5rem;
|
| 151 |
border: 2px dashed #3498DB;
|
| 152 |
border-radius: 10px;
|
| 153 |
padding: 10px;
|
| 154 |
}
|
| 155 |
-
|
| 156 |
.footer {
|
| 157 |
text-align: center;
|
| 158 |
margin-top: 2rem;
|
|
|
|
| 40 |
colors = np.random.randint(0, 255, size=(len(model.names), 3), dtype=np.uint8)
|
| 41 |
|
| 42 |
def process_video(video_path):
|
| 43 |
+
# Fix: Handle different types of input from Gradio
|
| 44 |
+
if isinstance(video_path, dict) and 'name' in video_path:
|
| 45 |
+
video_path = video_path['name']
|
| 46 |
+
|
| 47 |
cap = cv2.VideoCapture(video_path)
|
| 48 |
|
| 49 |
if not cap.isOpened():
|
|
|
|
| 121 |
margin: 1.5rem 0;
|
| 122 |
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
| 123 |
}
|
|
|
|
| 124 |
.gradio-container {
|
| 125 |
background-color: #F5F7FA;
|
| 126 |
}
|
|
|
|
| 127 |
.tab-item {
|
| 128 |
background-color: white;
|
| 129 |
border-radius: 10px;
|
|
|
|
| 131 |
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 132 |
margin: 10px;
|
| 133 |
}
|
|
|
|
| 134 |
.button-row {
|
| 135 |
display: flex;
|
| 136 |
justify-content: space-around;
|
| 137 |
margin: 1rem 0;
|
| 138 |
}
|
|
|
|
| 139 |
#video-process-btn, #submit-btn {
|
| 140 |
background-color: #3498DB;
|
| 141 |
border: none;
|
| 142 |
}
|
|
|
|
| 143 |
#clear-btn {
|
| 144 |
background-color: #E74C3C;
|
| 145 |
border: none;
|
| 146 |
}
|
|
|
|
| 147 |
.output-container {
|
| 148 |
margin-top: 1.5rem;
|
| 149 |
border: 2px dashed #3498DB;
|
| 150 |
border-radius: 10px;
|
| 151 |
padding: 10px;
|
| 152 |
}
|
|
|
|
| 153 |
.footer {
|
| 154 |
text-align: center;
|
| 155 |
margin-top: 2rem;
|