Skip to content

Commit d2b802b

Browse files
Fix batch analysis reporting: properly count analyzed vs unscored images
Images without OOD scores (never run through Discovery) were being silently skipped, causing "Analyzed: 0" in the report. Now correctly separates scored images from unscored ones and reports both counts. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1a27427 commit d2b802b

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

ui/discovery_panel.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -871,39 +871,53 @@ def run_analysis():
871871

872872
analyzed = 0
873873
anomalies = 0
874+
skipped = 0
875+
errors = 0
874876

875877
for i, img in enumerate(images):
876878
image_id = img.get("id")
877-
ood_score = img.get("ood_score") or 0
879+
ood_score = img.get("ood_score")
878880
filename = img.get("filename", "")
879881

882+
# Skip images with no OOD score (never analyzed)
883+
if ood_score is None or ood_score == 0:
884+
skipped += 1
885+
if (i + 1) % 100 == 0:
886+
self.log_signal.emit(f" Progress: {i+1}/{len(images)}")
887+
continue
888+
880889
# Check if above threshold
881890
is_anomaly = ood_score >= threshold
882891

883892
# Update database
884893
try:
885-
httpx.patch(
894+
resp = httpx.patch(
886895
f"http://localhost:8000/images/{image_id}",
887896
json={"is_anomaly": is_anomaly},
888897
timeout=10.0,
889898
)
899+
resp.raise_for_status()
890900

891901
analyzed += 1
892902
if is_anomaly:
893903
anomalies += 1
894904
if anomalies <= 20: # Only log first 20
895-
self.log_signal.emit(f" ✓ ANOMALY: {filename[:30]} (score={ood_score:.2f})")
896-
except:
897-
pass
905+
self.log_signal.emit(f" ✓ ANOMALY: {filename[:40]} (score={ood_score:.3f})")
906+
except Exception as e:
907+
errors += 1
898908

899909
# Progress every 100 images
900910
if (i + 1) % 100 == 0:
901-
self.log_signal.emit(f" Progress: {i+1}/{len(images)}")
911+
self.log_signal.emit(f" Progress: {i+1}/{len(images)} (anomalies so far: {anomalies})")
902912

903913
self.log_signal.emit(f"\n=== Batch Analysis Complete ===")
904-
self.log_signal.emit(f" Analyzed: {analyzed}")
905-
self.log_signal.emit(f" Anomalies: {anomalies}")
914+
self.log_signal.emit(f" Total images: {len(images)}")
915+
self.log_signal.emit(f" With OOD scores: {analyzed}")
916+
self.log_signal.emit(f" No OOD score (need Discovery): {skipped}")
917+
self.log_signal.emit(f" Anomalies flagged: {anomalies}")
906918
self.log_signal.emit(f" Rate: {anomalies/max(1,analyzed)*100:.1f}%")
919+
if errors > 0:
920+
self.log_signal.emit(f" Errors: {errors}")
907921
self.log_signal.emit(f"\nGo to Verify tab to cross-reference anomalies!")
908922

909923
except Exception as e:

0 commit comments

Comments
 (0)