Skip to content

feat(detections): store a native resolution crop per bbox - #749

Open
MateoLostanlen wants to merge 3 commits into
mainfrom
feat/detection-native-crops
Open

MateoLostanlen wants to merge 3 commits into
mainfrom
feat/detection-native-crops

Conversation

@MateoLostanlen

Copy link
Copy Markdown
Member
  • Why: the engine will run detection on native 4K frames. To retrain the model on them we need native resolution images, and today the API only keeps the downscaled frame and a 224x224 crop.
  • What: POST /detections accepts one native_crop file per bbox and native_crop_windows, the position of each crop in the full frame. Both are stored on the detection (new nullable columns, with a migration) and deleted with the detection or its camera.
  • The existing crop field is unchanged, so engines that are not updated keep working.
  • pyroclient: create_detection takes native_crops and native_crop_windows.

The engine can send, for each bbox, a region of the camera frame at its
native resolution and the position of that region in the full frame.
Both are stored on the detection and deleted with it or with its camera.
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "b7d1e4a2c9f6"

# revision identifiers, used by Alembic.
revision: str = "b7d1e4a2c9f6"
down_revision: Union[str, None] = "94a223eae6ac"
# revision identifiers, used by Alembic.
revision: str = "b7d1e4a2c9f6"
down_revision: Union[str, None] = "94a223eae6ac"
branch_labels: Union[str, Sequence[str], None] = None
revision: str = "b7d1e4a2c9f6"
down_revision: Union[str, None] = "94a223eae6ac"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
# order. Up to 6 decimals: 3 would be about 4 px on a 4K frame, too coarse to map labels to the crop.
WINDOW_FLOAT_PATTERN = r"(0?\.[0-9]{1,6}|0|1)"
WINDOW_PATTERN = rf"\({WINDOW_FLOAT_PATTERN},{WINDOW_FLOAT_PATTERN},{WINDOW_FLOAT_PATTERN},{WINDOW_FLOAT_PATTERN}\)"
WINDOWS_PATTERN = rf"^\[({WINDOW_PATTERN}(,{WINDOW_PATTERN})*)?\]$"
WINDOW_PATTERN = rf"\({WINDOW_FLOAT_PATTERN},{WINDOW_FLOAT_PATTERN},{WINDOW_FLOAT_PATTERN},{WINDOW_FLOAT_PATTERN}\)"
WINDOWS_PATTERN = rf"^\[({WINDOW_PATTERN}(,{WINDOW_PATTERN})*)?\]$"
# 37 chars per window, plus the separating commas and the brackets
MAX_WINDOWS_STR_LENGTH = settings.MAX_BOXES_PER_DETECTION * 38 + 1
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.79%. Comparing base (b0851a0) to head (6cb1a02).

Files with missing lines Patch % Lines
client/pyroclient/client.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #749      +/-   ##
==========================================
+ Coverage   91.83%   95.79%   +3.95%     
==========================================
  Files           3       65      +62     
  Lines         147     3806    +3659     
==========================================
+ Hits          135     3646    +3511     
- Misses         12      160     +148     
Flag Coverage Δ
backend 95.96% <100.00%> (?)
client 91.92% <94.11%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The API now rejects more than 5 bboxes whatever their formatting, and a
native crop over 1 MB. pyroclient refuses such a crop before sending it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant