Commit 4e33f96
fix(ml): create null detection markers only after real saves succeed
Issue #1310: null detections (empty-bbox sentinels marking "image processed,
nothing found") were created before create_detections / create_classifications /
create_and_update_occurrences_for_detections ran. Two consequences:
1. If any of those downstream steps failed, the image was already flagged as
processed via the null marker — filter_processed_images would skip it on the
next run, leaving the image permanently in a "processed but no detections"
state. Observed on project 171 (400 captures with only null detections).
2. create_and_update_occurrences_for_detections iterated every detection
including nulls, so each null marker spawned a phantom Occurrence with
determination=NULL.
Fix in ami/ml/models/pipeline.py save_results:
- Run create_detections / create_classifications / create_and_update_occurrences
on the real DetectionResponses only.
- After those succeed, build null DetectionResponses for images that ended up
without any detections and persist them via a second create_detections call.
- Null responses never enter the classification / occurrence loops, so no
phantom Occurrence is created even in the happy path.
Tests in ami/ml/tests.py TestPipeline:
- test_null_detection_does_not_create_phantom_occurrence: asserts the happy
path "pipeline found nothing" creates the null marker but no Occurrence.
- test_captures_not_marked_processed_after_failure: asserts that when a
downstream step (create_classifications) raises, the image without a real
detection is left unmarked and filter_processed_images re-yields it.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent f4fb6f1 commit 4e33f96
2 files changed
Lines changed: 89 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
952 | 952 | | |
953 | 953 | | |
954 | 954 | | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | 955 | | |
965 | 956 | | |
966 | 957 | | |
| |||
981 | 972 | | |
982 | 973 | | |
983 | 974 | | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
984 | 991 | | |
985 | 992 | | |
986 | 993 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
1024 | 1025 | | |
1025 | 1026 | | |
1026 | 1027 | | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1027 | 1100 | | |
1028 | 1101 | | |
1029 | 1102 | | |
| |||
0 commit comments