@@ -88,12 +88,18 @@ def save_results(
88
88
algorithm = self .name ,
89
89
timestamp = datetime .datetime .now (),
90
90
)
91
- detection . classifications . append ( classification )
91
+ self . update_classification ( detection , classification )
92
92
print (detection )
93
93
self .results .extend (self .detections )
94
94
logger .info (f"Saving { len (self .results )} detections with classifications" )
95
95
return self .results
96
96
97
+ def update_classification (self , detection : Detection , new_classification : Classification ) -> None :
98
+ # Remove all existing classifications from this algorithm
99
+ detection .classifications = [c for c in detection .classifications if c .algorithm != self .name ]
100
+ # Add the new classification for this algorithm
101
+ detection .classifications .append (new_classification )
102
+
97
103
def run (self ) -> list [Detection ]:
98
104
super ().run ()
99
105
return self .results
@@ -129,11 +135,8 @@ def save_results(
129
135
terminal = False ,
130
136
)
131
137
print (detection )
132
- if self .filter_results :
133
- if classification .classification == self .positive_binary_label :
134
- detection .classifications .append (classification )
135
- else :
136
- detection .classifications .append (classification )
138
+ if not self .filter_results or classification .classification == self .positive_binary_label :
139
+ self .update_classification (detection , classification )
137
140
138
141
self .results .extend (self .detections )
139
142
logger .info (f"Saving { len (self .results )} detections with classifications" )
0 commit comments