Skip to content

Commit 1cc2088

Browse files
basakcapdnoliver
andauthored
Add Model Parameters (open-edge-platform#142)
* Add new model parameters: batch size, nireq, and inference interval * Add input fields to capture these parameter values from the user * Updated relevant pipeline to utilize the new inputs Co-authored-by: Nicolas Oliver <[email protected]>
1 parent 5061883 commit 1cc2088

File tree

2 files changed

+61
-6
lines changed

2 files changed

+61
-6
lines changed

tools/visual-pipeline-and-platform-evaluation-tool/app.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,35 @@ def create_interface():
422422
value=preferred_device,
423423
)
424424

425+
# Batch size
426+
batch_size = gr.Slider(
427+
minimum=0,
428+
maximum=1024,
429+
value=0,
430+
step=1,
431+
label="Batch Size",
432+
interactive=True,
433+
)
434+
435+
# Inference interval
436+
inference_interval = gr.Slider(
437+
minimum=1,
438+
maximum=1800,
439+
value=1,
440+
step=1,
441+
label="Inference Interval",
442+
interactive=True,
443+
)
444+
445+
# Number of inference requests (nireq)
446+
nireq = gr.Slider(
447+
minimum=0,
448+
maximum=1024,
449+
value=0,
450+
step=1,
451+
label="Number of Inference Requests (nireq)",
452+
interactive=True,
453+
)
425454
# This elements are not used in the current version of the app
426455
# # Object classification accordion
427456
# object_classification_accordion = gr.Accordion(
@@ -491,9 +520,13 @@ def on_run(
491520
# This elements are not used in the current version of the app
492521
# object_classification_model,
493522
# object_classification_device,
523+
batch_size,
524+
inference_interval,
525+
nireq,
494526
input_video_player,
495527
):
496528

529+
497530
random_string = "".join(
498531
random.choices(string.ascii_lowercase + string.digits, k=6)
499532
)
@@ -508,6 +541,9 @@ def on_run(
508541

509542
param_grid = {
510543
"object_detection_device": object_detection_device.split(", "),
544+
"batch_size": [batch_size],
545+
"inference_interval": [inference_interval],
546+
"nireq": [nireq],
511547
# This elements are not used in the current version of the app
512548
# "vehicle_classification_device": object_classification_device.split(
513549
# ", "
@@ -621,6 +657,9 @@ def on_run(
621657
# This elements are not used in the current version of the app
622658
# object_classification_model,
623659
# object_classification_device,
660+
batch_size,
661+
inference_interval,
662+
nireq,
624663
input_video_player,
625664
],
626665
outputs=[output_video_player, cpu_metrics_plot, gpu_time_series_plot],
@@ -643,6 +682,9 @@ def on_run(
643682
with object_detection_accordion.render():
644683
object_detection_model.render()
645684
object_detection_device.render()
685+
batch_size.render()
686+
inference_interval.render()
687+
nireq.render()
646688

647689
# This elements are not used in the current version of the app
648690
# with object_classification_accordion.render():

tools/visual-pipeline-and-platform-evaluation-tool/pipeline.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@ def __init__(self):
163163
"gvadetect "
164164
" model={OBJECT_DETECTION_MODEL_PATH} "
165165
" model-proc={OBJECT_DETECTION_MODEL_PROC} "
166-
" inference-interval=3 "
167166
" model-instance-id=detect0 "
168167
" pre-process-backend={object_detection_pre_process_backend} "
169-
" device={object_detection_device} ! "
168+
" device={object_detection_device} "
169+
" batch-size={batch_size} "
170+
" inference-interval={inference_interval} "
171+
" nireq={nireq} ! "
170172
"queue2 "
171173
" max-size-buffers=0 "
172174
" max-size-bytes=0 "
@@ -280,7 +282,6 @@ def evaluate(
280282
postprocessing=_postprocessing_element
281283
)
282284

283-
284285
# Evaluate the pipeline
285286
return "gst-launch-1.0 -q " + compositor + " " + streams
286287

@@ -294,13 +295,25 @@ def evaluate(
294295
print(
295296
"Evaluate:",
296297
pipeline.evaluate(
297-
{
298+
constant = {
298299
"VIDEO_OUTPUT_PATH": "output.mp4",
299300
"VIDEO_PATH": "input.mp4",
300301
"OBJECT_DETECTION_MODEL_PATH": "model.xml",
301302
"OBJECT_DETECTION_MODEL_PROC": "model_proc.xml",
302303
},
303-
{"object_detection_device": "CPU"},
304-
2,
304+
parameters = {
305+
"object_detection_device": "CPU",
306+
"batch_size": 16,
307+
"inference_interval": 2,
308+
"nireq": 4,
309+
},
310+
regular_channels = 2,
311+
inference_channels = 1,
312+
elements = [
313+
"compositor",
314+
"x264enc",
315+
"decodebin",
316+
"videoscale"
317+
]
305318
),
306319
)

0 commit comments

Comments
 (0)