Update app.py
Browse files
app.py
CHANGED
@@ -45,6 +45,9 @@ if video_file is not None:
|
|
45 |
# Collect frames in a list
|
46 |
frames = []
|
47 |
|
|
|
|
|
|
|
48 |
while cap.isOpened() and not processing_interrupted:
|
49 |
alert_flag = False
|
50 |
alert_reason = []
|
@@ -56,6 +59,13 @@ if video_file is not None:
|
|
56 |
# st.warning("Can't receive frame (stream end?). Exiting ...")
|
57 |
break
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
if success:
|
60 |
# Check if the stop button is clicked
|
61 |
if stop_button:
|
@@ -124,3 +134,12 @@ if video_file is not None:
|
|
124 |
progress_bar_display = st.progress(0)
|
125 |
fps_delay = 1 / 24 # Delay to achieve 24 FPS
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Collect frames in a list
|
46 |
frames = []
|
47 |
|
48 |
+
# Set the desired size as a percentage of the original size
|
49 |
+
target_size_percentage = 0.65
|
50 |
+
|
51 |
while cap.isOpened() and not processing_interrupted:
|
52 |
alert_flag = False
|
53 |
alert_reason = []
|
|
|
59 |
# st.warning("Can't receive frame (stream end?). Exiting ...")
|
60 |
break
|
61 |
|
62 |
+
# Calculate the target size
|
63 |
+
target_width = int(frame.shape[1] * target_size_percentage)
|
64 |
+
target_height = int(frame.shape[0] * target_size_percentage)
|
65 |
+
|
66 |
+
# Resize the frame
|
67 |
+
frame = cv2.resize(frame, (target_width, target_height))
|
68 |
+
|
69 |
if success:
|
70 |
# Check if the stop button is clicked
|
71 |
if stop_button:
|
|
|
134 |
progress_bar_display = st.progress(0)
|
135 |
fps_delay = 1 / 24 # Delay to achieve 24 FPS
|
136 |
|
137 |
+
for i, frame in enumerate(frames):
|
138 |
+
video_placeholder.image(frame, channels="BGR", caption="YOLOv8 Inference")
|
139 |
+
# Update display progress bar
|
140 |
+
progress_bar_display.progress((i + 1) / len(frames))
|
141 |
+
# Introduce a delay to achieve 24 FPS
|
142 |
+
time.sleep(fps_delay)
|
143 |
+
|
144 |
+
# Display completion message
|
145 |
+
progress_bar_processing_slot.text("Video Playback Finished!")
|