Skip to content

Dynamic and Batch Support for Object Detector#29

Merged
kevchengcodes merged 4 commits into
apple:mainfrom
kevchengcodes:obj_detr_dynamic
Jun 15, 2026
Merged

Dynamic and Batch Support for Object Detector#29
kevchengcodes merged 4 commits into
apple:mainfrom
kevchengcodes:obj_detr_dynamic

Conversation

@kevchengcodes

Copy link
Copy Markdown
Contributor

Summary

Enables the ObjectDetector to run dynamic models as well as static models with batch_size > 1.

Changes include resolving dynamic dimensions similar to how llm-runner does it, constructing a batched input tensor based on the list of input images, and post-processing each output.

Models can have dynamic batch size, image input height/width. Note that batched images will be resized to a common size when constructing the (B,C,H,W) input tensor. Users can optionally input a custom input height/width for their dynamic batch.

Verification

Tested with YoloS:

uv run models/yolo/export.py --dynamic
swift run -c release object-detector --model exports/yolos-base_float32_dynamic.aimodel --image img.png --output-image out.png

New unit tests to validate batch support is working.

@kevchengcodes kevchengcodes self-assigned this Jun 12, 2026
Comment thread swift/Sources/CoreAIObjectDetector/ObjectDetector.swift Outdated
Comment thread swift/Sources/CoreAIObjectDetector/ObjectDetector.swift Outdated
@carinapeng carinapeng self-requested a review June 12, 2026 21:38

@carinapeng carinapeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@kevchengcodes kevchengcodes merged commit dd124a8 into apple:main Jun 15, 2026
3 checks passed
@kevchengcodes kevchengcodes deleted the obj_detr_dynamic branch June 16, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants