Commit ·
44960ec
1
Parent(s): c2a5995
ft:tabs_reordering
Browse files
app.py
CHANGED
|
@@ -199,78 +199,7 @@ def video_stream_HIKvision(video_address, frame_rate = ""):
|
|
| 199 |
yield fall_back_frame
|
| 200 |
# Gradio interface
|
| 201 |
with gr.Blocks() as demo:
|
| 202 |
-
|
| 203 |
-
with gr.Row():
|
| 204 |
-
with gr.Column():
|
| 205 |
-
with gr.Row():
|
| 206 |
-
video_address = gr.Textbox(label="Video Source Address")
|
| 207 |
-
with gr.Row():
|
| 208 |
-
example_addresses = gr.Examples(
|
| 209 |
-
examples=EXAMPLE_VIDEOS_LIST+[
|
| 210 |
-
'rtsp://admin:Admin123@192.168.254.200:554/Streaming/Channels/101',
|
| 211 |
-
'rtsp://admin:Admin123@192.168.254.201:554/Streaming/Channels/101',
|
| 212 |
-
'rtsp://admin:Admin123@192.168.254.202:554/Streaming/Channels/101',
|
| 213 |
-
'rtsp://admin:Admin123@192.168.254.203:554/Streaming/Channels/101'
|
| 214 |
-
],
|
| 215 |
-
inputs=[video_address],
|
| 216 |
-
)
|
| 217 |
-
|
| 218 |
-
with gr.Column():
|
| 219 |
-
webcam_img_HIKvision = gr.Interface(video_stream_HIKvision,
|
| 220 |
-
inputs=[video_address, gr.Textbox(label="Acquisition: Enter the frame rate", value = 2.0)], #
|
| 221 |
-
outputs="image")
|
| 222 |
-
with gr.Row():
|
| 223 |
-
with gr.Column():
|
| 224 |
-
optical_flow_img = gr.Interface(compute_optical_flow,
|
| 225 |
-
inputs=gr.Slider(label="Optical Flow: Noise Tolerance", minimum=0.0, maximum=1.0, value=0.4),
|
| 226 |
-
outputs=gr.Image(),#,"image",
|
| 227 |
-
)
|
| 228 |
-
with gr.Column():
|
| 229 |
-
detection_img = gr.Interface(object_detection_stream,
|
| 230 |
-
inputs=gr.Textbox(label="Classes: Enter the classes", value = "one bird, one airplane, one kite,a flying object,sky"),
|
| 231 |
-
outputs="image")
|
| 232 |
-
|
| 233 |
-
with gr.Tab("Using a Hikvision Camera (Change Detection)"):
|
| 234 |
-
with gr.Row():
|
| 235 |
-
with gr.Column():
|
| 236 |
-
with gr.Row():
|
| 237 |
-
video_address_CD = gr.Textbox(label="Hikvision Camera Address (RTSP)")
|
| 238 |
-
with gr.Row():
|
| 239 |
-
example_addresses_CD = gr.Examples(
|
| 240 |
-
examples=EXAMPLE_VIDEOS_LIST+[
|
| 241 |
-
'rtsp://admin:Admin123@192.168.254.200:554/Streaming/Channels/101',
|
| 242 |
-
'rtsp://admin:Admin123@192.168.254.201:554/Streaming/Channels/101',
|
| 243 |
-
'rtsp://admin:Admin123@192.168.254.202:554/Streaming/Channels/101',
|
| 244 |
-
'rtsp://admin:Admin123@192.168.254.203:554/Streaming/Channels/101'
|
| 245 |
-
],
|
| 246 |
-
inputs=[video_address_CD],
|
| 247 |
-
)
|
| 248 |
-
|
| 249 |
-
with gr.Column():
|
| 250 |
-
hikvision_stream_CD = gr.Interface(
|
| 251 |
-
video_stream_HIKvision,
|
| 252 |
-
inputs=[
|
| 253 |
-
video_address_CD,
|
| 254 |
-
gr.Textbox(label="Acquisition: Enter the frame rate", value=2.0)
|
| 255 |
-
],
|
| 256 |
-
outputs="image"
|
| 257 |
-
)
|
| 258 |
-
|
| 259 |
-
with gr.Row():
|
| 260 |
-
with gr.Column():
|
| 261 |
-
optical_flow_img_HIK_CD = gr.Interface(
|
| 262 |
-
compute_optical_flow,
|
| 263 |
-
inputs=gr.Slider(label="Optical Flow: Noise Tolerance", minimum=0.0, maximum=1.0, value=0.4),
|
| 264 |
-
outputs="image"
|
| 265 |
-
)
|
| 266 |
-
|
| 267 |
-
with gr.Column():
|
| 268 |
-
detection_img_HIK_CD = gr.Interface(
|
| 269 |
-
change_detection_stream,
|
| 270 |
-
inputs=gr.Textbox(label="Changes will be detected here", value="DUMMY"),
|
| 271 |
-
outputs="image"
|
| 272 |
-
)
|
| 273 |
-
|
| 274 |
with gr.Tab("Using a custom Video"):
|
| 275 |
with gr.Row():
|
| 276 |
with gr.Column():
|
|
@@ -399,6 +328,80 @@ with gr.Blocks() as demo:
|
|
| 399 |
value = "DUMMY"),
|
| 400 |
outputs="image")
|
| 401 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
with gr.Tab("Runtime Histograms"):
|
| 403 |
def plot_histogram(data, title, color):
|
| 404 |
plt.figure(figsize=(9, 5))
|
|
|
|
| 199 |
yield fall_back_frame
|
| 200 |
# Gradio interface
|
| 201 |
with gr.Blocks() as demo:
|
| 202 |
+
gr.Markdown("### Birds Detection Real Time (suitable for CPU Embedded Systems)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
with gr.Tab("Using a custom Video"):
|
| 204 |
with gr.Row():
|
| 205 |
with gr.Column():
|
|
|
|
| 328 |
value = "DUMMY"),
|
| 329 |
outputs="image")
|
| 330 |
|
| 331 |
+
with gr.Tab("Using a Hikvision Camera"):
|
| 332 |
+
with gr.Row():
|
| 333 |
+
with gr.Column():
|
| 334 |
+
with gr.Row():
|
| 335 |
+
video_address = gr.Textbox(label="Video Source Address")
|
| 336 |
+
with gr.Row():
|
| 337 |
+
example_addresses = gr.Examples(
|
| 338 |
+
examples=EXAMPLE_VIDEOS_LIST+[
|
| 339 |
+
'rtsp://admin:Admin123@192.168.254.200:554/Streaming/Channels/101',
|
| 340 |
+
'rtsp://admin:Admin123@192.168.254.201:554/Streaming/Channels/101',
|
| 341 |
+
'rtsp://admin:Admin123@192.168.254.202:554/Streaming/Channels/101',
|
| 342 |
+
'rtsp://admin:Admin123@192.168.254.203:554/Streaming/Channels/101'
|
| 343 |
+
],
|
| 344 |
+
inputs=[video_address],
|
| 345 |
+
)
|
| 346 |
+
|
| 347 |
+
with gr.Column():
|
| 348 |
+
webcam_img_HIKvision = gr.Interface(video_stream_HIKvision,
|
| 349 |
+
inputs=[video_address, gr.Textbox(label="Acquisition: Enter the frame rate", value = 2.0)], #
|
| 350 |
+
outputs="image")
|
| 351 |
+
with gr.Row():
|
| 352 |
+
with gr.Column():
|
| 353 |
+
optical_flow_img = gr.Interface(compute_optical_flow,
|
| 354 |
+
inputs=gr.Slider(label="Optical Flow: Noise Tolerance", minimum=0.0, maximum=1.0, value=0.4),
|
| 355 |
+
outputs=gr.Image(),#,"image",
|
| 356 |
+
)
|
| 357 |
+
with gr.Column():
|
| 358 |
+
detection_img = gr.Interface(object_detection_stream,
|
| 359 |
+
inputs=gr.Textbox(label="Classes: Enter the classes", value = "one bird, one airplane, one kite,a flying object,sky"),
|
| 360 |
+
outputs="image")
|
| 361 |
+
|
| 362 |
+
with gr.Tab("Using a Hikvision Camera (Change Detection)"):
|
| 363 |
+
with gr.Row():
|
| 364 |
+
with gr.Column():
|
| 365 |
+
with gr.Row():
|
| 366 |
+
video_address_CD = gr.Textbox(label="Hikvision Camera Address (RTSP)")
|
| 367 |
+
with gr.Row():
|
| 368 |
+
example_addresses_CD = gr.Examples(
|
| 369 |
+
examples=EXAMPLE_VIDEOS_LIST+[
|
| 370 |
+
'rtsp://admin:Admin123@192.168.254.200:554/Streaming/Channels/101',
|
| 371 |
+
'rtsp://admin:Admin123@192.168.254.201:554/Streaming/Channels/101',
|
| 372 |
+
'rtsp://admin:Admin123@192.168.254.202:554/Streaming/Channels/101',
|
| 373 |
+
'rtsp://admin:Admin123@192.168.254.203:554/Streaming/Channels/101'
|
| 374 |
+
],
|
| 375 |
+
inputs=[video_address_CD],
|
| 376 |
+
)
|
| 377 |
+
|
| 378 |
+
with gr.Column():
|
| 379 |
+
hikvision_stream_CD = gr.Interface(
|
| 380 |
+
video_stream_HIKvision,
|
| 381 |
+
inputs=[
|
| 382 |
+
video_address_CD,
|
| 383 |
+
gr.Textbox(label="Acquisition: Enter the frame rate", value=2.0)
|
| 384 |
+
],
|
| 385 |
+
outputs="image"
|
| 386 |
+
)
|
| 387 |
+
|
| 388 |
+
with gr.Row():
|
| 389 |
+
with gr.Column():
|
| 390 |
+
optical_flow_img_HIK_CD = gr.Interface(
|
| 391 |
+
compute_optical_flow,
|
| 392 |
+
inputs=gr.Slider(label="Optical Flow: Noise Tolerance", minimum=0.0, maximum=1.0, value=0.4),
|
| 393 |
+
outputs="image"
|
| 394 |
+
)
|
| 395 |
+
|
| 396 |
+
with gr.Column():
|
| 397 |
+
detection_img_HIK_CD = gr.Interface(
|
| 398 |
+
change_detection_stream,
|
| 399 |
+
inputs=gr.Textbox(label="Changes will be detected here", value="DUMMY"),
|
| 400 |
+
outputs="image"
|
| 401 |
+
)
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
|
| 405 |
with gr.Tab("Runtime Histograms"):
|
| 406 |
def plot_histogram(data, title, color):
|
| 407 |
plt.figure(figsize=(9, 5))
|