Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,8 +37,14 @@ def process_video(uploaded_file):
|
|
| 37 |
|
| 38 |
# Read the video file
|
| 39 |
video = cv2.VideoCapture(temp_file_path)
|
|
|
|
| 40 |
frames = []
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
while True:
|
| 43 |
ret, frame = video.read()
|
| 44 |
if not ret:
|
|
@@ -50,6 +56,11 @@ def process_video(uploaded_file):
|
|
| 50 |
# Process the results and draw boxes on the current frame
|
| 51 |
processed_frame = process_results(results, frame)
|
| 52 |
frames.append(processed_frame) # Save the processed frame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
video.release()
|
| 55 |
|
|
@@ -61,6 +72,11 @@ def process_video(uploaded_file):
|
|
| 61 |
out.write(frame) # Write each processed frame to the video
|
| 62 |
|
| 63 |
out.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
def main():
|
|
|
|
| 37 |
|
| 38 |
# Read the video file
|
| 39 |
video = cv2.VideoCapture(temp_file_path)
|
| 40 |
+
total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) # Get the total number of frames
|
| 41 |
frames = []
|
| 42 |
|
| 43 |
+
# Create a Streamlit progress bar
|
| 44 |
+
progress_bar = st.progress(0)
|
| 45 |
+
|
| 46 |
+
current_frame = 0
|
| 47 |
+
|
| 48 |
while True:
|
| 49 |
ret, frame = video.read()
|
| 50 |
if not ret:
|
|
|
|
| 56 |
# Process the results and draw boxes on the current frame
|
| 57 |
processed_frame = process_results(results, frame)
|
| 58 |
frames.append(processed_frame) # Save the processed frame
|
| 59 |
+
|
| 60 |
+
current_frame += 1
|
| 61 |
+
# Update the progress bar
|
| 62 |
+
progress_percentage = current_frame / total_frames
|
| 63 |
+
progress_bar.progress(progress_percentage)
|
| 64 |
|
| 65 |
video.release()
|
| 66 |
|
|
|
|
| 72 |
out.write(frame) # Write each processed frame to the video
|
| 73 |
|
| 74 |
out.release()
|
| 75 |
+
|
| 76 |
+
# Complete the progress bar
|
| 77 |
+
progress_bar.progress(1)
|
| 78 |
+
st.success('Video processing complete!')
|
| 79 |
+
|
| 80 |
|
| 81 |
|
| 82 |
def main():
|