Update app.py
Browse files
app.py
CHANGED
@@ -147,17 +147,16 @@ def create_heatmap(frame_scores, current_frame):
|
|
147 |
|
148 |
return tmp_file.name
|
149 |
|
150 |
-
def load_sample_frame(video_path,
|
151 |
cap = cv2.VideoCapture(video_path)
|
152 |
if not cap.isOpened():
|
153 |
return None
|
154 |
|
155 |
-
|
|
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_number)
|
161 |
|
162 |
ret, frame = cap.read()
|
163 |
cap.release()
|
@@ -183,7 +182,10 @@ def gradio_app():
|
|
183 |
heatmap_output = gr.Image(label="Detection Heatmap")
|
184 |
output_image = gr.Image(label="Processed Frame")
|
185 |
error_output = gr.Textbox(label="Error Messages", visible=False)
|
186 |
-
sample_video_frame = gr.Image(
|
|
|
|
|
|
|
187 |
use_sample_button = gr.Button("Use Sample Video")
|
188 |
progress_bar = gr.Progress()
|
189 |
|
|
|
147 |
|
148 |
return tmp_file.name
|
149 |
|
150 |
+
def load_sample_frame(video_path, target_frame=87, original_fps=30, processing_fps=1):
|
151 |
cap = cv2.VideoCapture(video_path)
|
152 |
if not cap.isOpened():
|
153 |
return None
|
154 |
|
155 |
+
# Calculate the corresponding frame number in the original video
|
156 |
+
original_frame_number = int(target_frame * (original_fps / processing_fps))
|
157 |
|
158 |
+
# Set the frame position
|
159 |
+
cap.set(cv2.CAP_PROP_POS_FRAMES, original_frame_number)
|
|
|
|
|
160 |
|
161 |
ret, frame = cap.read()
|
162 |
cap.release()
|
|
|
182 |
heatmap_output = gr.Image(label="Detection Heatmap")
|
183 |
output_image = gr.Image(label="Processed Frame")
|
184 |
error_output = gr.Textbox(label="Error Messages", visible=False)
|
185 |
+
sample_video_frame = gr.Image(
|
186 |
+
value=load_sample_frame("Drone Video of African Wildlife Wild Botswan.mp4", target_frame=87),
|
187 |
+
label="Drone Video of African Wildlife Wild Botswan by wildimagesonline.com - Sample Video Frame (Frame 87 at 1 FPS)"
|
188 |
+
)
|
189 |
use_sample_button = gr.Button("Use Sample Video")
|
190 |
progress_bar = gr.Progress()
|
191 |
|