Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,6 +102,7 @@ def process_video(input_video):
|
|
| 102 |
|
| 103 |
# Convert the resized frame to grayscale
|
| 104 |
gray_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2GRAY)
|
|
|
|
| 105 |
input_frame = cv2.merge([gray_frame, gray_frame, gray_frame]) # Convert grayscale to 3 channels
|
| 106 |
|
| 107 |
results = model.predict(input_frame)
|
|
@@ -123,6 +124,12 @@ def process_video(input_video):
|
|
| 123 |
|
| 124 |
# Ensure the frame is in RGB format before appending to the writer
|
| 125 |
rgb_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
writer.append_data(rgb_frame)
|
| 127 |
|
| 128 |
cap.release()
|
|
|
|
| 102 |
|
| 103 |
# Convert the resized frame to grayscale
|
| 104 |
gray_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2GRAY)
|
| 105 |
+
# Convert grayscale to 3 channels (RGB format)
|
| 106 |
input_frame = cv2.merge([gray_frame, gray_frame, gray_frame]) # Convert grayscale to 3 channels
|
| 107 |
|
| 108 |
results = model.predict(input_frame)
|
|
|
|
| 124 |
|
| 125 |
# Ensure the frame is in RGB format before appending to the writer
|
| 126 |
rgb_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
| 127 |
+
|
| 128 |
+
# Ensure the frame has the correct shape (640x640x3)
|
| 129 |
+
if rgb_frame.shape[2] != 3:
|
| 130 |
+
print(f"Warning: Unexpected frame shape {rgb_frame.shape}, adjusting...")
|
| 131 |
+
rgb_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
| 132 |
+
|
| 133 |
writer.append_data(rgb_frame)
|
| 134 |
|
| 135 |
cap.release()
|