Skip to content

fix(api): keep per-object smoke_type in sequence-to-detection propagation - #150

Merged
MateoLostanlen merged 2 commits into
mainfrom
fix/per-object-smoke-type-propagation
Jul 15, 2026
Merged

fix(api): keep per-object smoke_type in sequence-to-detection propagation#150
MateoLostanlen merged 2 commits into
mainfrom
fix/per-object-smoke-type-propagation

Conversation

@MateoLostanlen

Copy link
Copy Markdown
Member
  • auto_create_detection_annotations applied smoke_types[0] to every pre-populated detection box, so sequences containing objects of different smoke types (e.g. one wildfire + one industrial) were mislabeled at the detection level.
  • Each prediction now inherits the type of the sequences_bbox object whose box matches it: exact coordinate match first (object boxes come from algo_predictions untouched), best IoU as a robustness fallback, and the sequence-wide first type only when a prediction overlaps no object box.
  • Adds a unit test on convert_algo_predictions_to_annotation (exact / IoU / no-overlap paths) and an end-to-end regression test (mixed wildfire+industrial sequence); both fail before the fix.

Fixes #142

…tion

auto_create_detection_annotations stamped smoke_types[0] on every
pre-populated detection box, so a sequence containing objects of
different smoke types (e.g. wildfire + industrial) was mislabeled at
the detection level.

Each prediction now takes the type of the sequences_bbox object whose
box matches it (exact coordinates first, best IoU as fallback); the
sequence-wide first type remains the fallback for predictions matching
no object box. Regression tests fail before the fix.

Fixes #142
The workflow test asserted the pre-#142 behavior (every detection box
stamped with smoke_types[0]); it now checks that each detection's
pre-populated box carries the type of the object annotated on it.
@Chouffe
Chouffe self-requested a review July 15, 2026 12:33

@Chouffe Chouffe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall LGTM! Have you verified this empirically with some sequences? Is there a way for me to reproduce it?

@MateoLostanlen

Copy link
Copy Markdown
Member Author

Yes — verified empirically against the local dev stack (docker compose -f annotation_api/docker-compose-dev.yml up -d --wait --build, API on localhost:5050), with one sequence + one detection carrying two model predictions (left box / right box), then a sequence annotation with a wildfire object on the left box and an industrial object on the right box, processing_stage=annotated to trigger the propagation.

Reading back GET /api/v1/annotations/detections/?sequence_id=...:

On main (bug):

sequence smoke_types: ['wildfire', 'industrial']
  box [0.1, 0.1, 0.2, 0.2] -> smoke_type=wildfire
  box [0.6, 0.6, 0.7, 0.7] -> smoke_type=wildfire   <- industrial object mislabeled

On this branch:

sequence smoke_types: ['wildfire', 'industrial']
  box [0.1, 0.1, 0.2, 0.2] -> smoke_type=wildfire
  box [0.6, 0.6, 0.7, 0.7] -> smoke_type=industrial

Two ways to reproduce:

  1. Automated — the end-to-end regression test seeds exactly this scenario through the API:
    cd annotation_api
    make test-specific TEST=tests/endpoints/test_sequence_annotations.py::test_true_positive_sequence_keeps_per_object_smoke_types
    # passes on this branch; to see it fail with the old behavior:
    git checkout main -- src/app/api/api_v1/endpoints/sequence_annotations.py
    make test-specific TEST=tests/endpoints/test_sequence_annotations.py::test_true_positive_sequence_keeps_per_object_smoke_types
    git checkout - -- src/app/api/api_v1/endpoints/sequence_annotations.py
  2. Manual — the scenario above via /docs or curl: create a sequence, one detection with two algo_predictions boxes, POST a sequence annotation (stage annotated) with two sequences_bbox objects of different smoke_type each referencing one of the prediction boxes, then read the auto-created detection annotation.

There is also a unit test covering the matching paths (exact coordinates / best-IoU fallback / no-overlap fallback to smoke_types[0]): test_convert_algo_predictions_uses_per_object_smoke_types.

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.

Sequence→detection propagation collapses per-object smoke_type to smoke_types[0]

2 participants