Edge inference and scene leakage
Quick answer
Edge inference runs a model close to the input source under device-specific resource limits. Vision evaluation must preserve scene isolation and measure the entire pipeline rather than just the model forward pass. Examples are static Python snippets tested locally on CPU; Torchvision is required for selected examples. ByteMind execution is unverified.
Scene isolation
train=["scene-a","scene-a","scene-b"]val=["scene-c"];test=["scene-b"]print(sorted((set(train)&set(val))|(set(train)&set(test))|(set(val)&set(test))))Expected output (locally tested): ['scene-b']. Repeated views within a partition are allowed; scene-b across partitions is leakage.
How it works
Split by original scene or capture session before augmentation, including crops and repeated views. For transfer learning, use only approved weights with verified licensing and preprocessing; freeze the feature extractor first, train a task head, then optionally fine-tune with a smaller learning rate using development data. In PyTorch, requires_grad=False freezes parameter gradients but does not freeze BatchNorm running statistics in train mode: choose mode explicitly. No external model is required here. Deployment latency includes decode, resize, model, NMS and mask restoration; report device, runtime, threads, batch size, resolution, warmup and p50/p95, memory and accuracy changes. Quantization reduces precision and may change predictions; verify supported operators and calibrate only on representative development data. Avoid claiming CPU simulation is an edge-device benchmark. Do not process faces, surveillance or personal images; use synthetic objects.
Freeze backbone and train head
import torchbackbone=torch.nn.Linear(3,4);head=torch.nn.Linear(4,2)backbone.requires_grad_(False);backbone.eval()head(backbone(torch.ones(1,3))).sum().backward()print(backbone.weight.grad is None,head.weight.grad is not None)print(1000*4,1000)Expected output (locally tested): True True 4000 1000. Frozen backbone has no parameter gradient. Raw FP32 versus INT8 bytes exclude metadata and activations.
Common mistakes
Do not split near-duplicate frames independently. Do not assume parameter count equals device memory or latency. Do not download unapproved checkpoints or use held-out test for calibration.
Practice and next steps
Audit scene overlap and estimate raw weight storage at FP32 and INT8. Explain why real runtime measurements can differ from these estimates.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Edge inference and scene leakage — knowledge check
Apply edge inference and scene leakage to small examples and debugging scenarios.
What is the split unit for related frames?
Does freezing parameter gradients automatically freeze BatchNorm running stats?
What should end-to-end edge latency include?
Where calibrate quantization?
Is packed weight size total runtime memory?