Find out why your detector shows old frames

Separate capture delay, queueing, inference, transfer, and display before choosing an accelerator.

Exercise brief·Intermediate·3 min read

Opening the Python editor…

Requirements and learning goals

Before you start

  • The Wendy starter project from the YOLO walkthrough
  • A working inference pipeline with timestamps

You will be able to

  • Measure end-to-end latency
  • Report percentiles
  • Avoid an ever-growing frame queue

The browser exercise above works without extra setup. The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?

Edge runs a trained model on a nearby device, such as a Jetson, instead of sending every input to a remote server. An accelerator is hardware that can speed up some model operations. This lesson helps you find the actual bottleneck before changing hardware, and check that a fast detector is acting on fresh images.

Declare the required GPU and device access, then inspect runtime evidence. Access to an accelerator does not prove the model uses it.

Measure observation age

Throughput counts completed work. measures how long one observation takes to become useful. A smooth camera feed can display detections from a second ago.

Give each frame an ID and capture time. Record preprocessing, queueing, inference, and consumption times. Use one monotonic clock for local intervals; cross-device timestamps need an explicit clock relationship.

Save this calculation as latency_summary.py beside detect.py in the starter project:

from statistics import median
from math import ceil
 
latencies = [31, 32, 30, 33, 35, 31, 34, 36, 90, 120]
ordered = sorted(latencies)
p95 = ordered[ceil(0.95 * len(ordered)) - 1]
print("median ms", median(ordered))
print("p95 ms", p95)

Stop the previous attached run with Ctrl+C and run it on the same Wendy target:

wendy run --env LESSON_SCRIPT=latency_summary.py

Expect median ms 33.5 and p95 ms 120 in the Wendy logs and the results page's run.log. These are calculations over sample numbers, not measurements of your target. The starter uses CPU inference even on a GPU-equipped device.

Replace these illustrative numbers with at least a hundred measured frames. Report startup separately and repeat after sustained operation.

Checkpoint 1 of 2

A controller should not act on observations older than 50 ms. The sample latencies give a median of 33.5 ms and a p95 of 120 ms. Does the pipeline meet that limit?

Commit to an answer. Every choice explains itself.

Bound the queue

If capture outpaces inference, an unlimited queue makes results progressively older. Live control often needs the newest waiting frame; archival processing may need every frame. State which policy you implement and count dropped frames.

Checkpoint 2 of 2

A camera captures 30 frames per second and inference completes 20 per second. Frames wait in an unlimited queue. What happens to the detections over time?

Commit to an answer. Every choice explains itself.

Verify accelerator use through the runtime's selected backend and profiling. Hardware access alone does not prove acceleration. Wendy's GPU guide describes target-specific resource exposure. When timing asynchronous execution, synchronize or use runtime timing events.

Common snag: timing only the GPU submission call. Also include decoding, transfers, and delivery to the consumer.

The Go2 assistant separates display from perception and checks capture viewpoint. Optional extension: inject inference delay and verify that your controller rejects observations that have become too old.

Can you do each of these?

  • Measure end-to-end latency
  • Report percentiles
  • Avoid an ever-growing frame queue

0 of 2 checkpoints solved. Try checkpoint 1

Speech and camera projects

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.