MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / compare_results

Function compare_results

tests/test_visual_only_compare.cpp:35–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35static bool compare_results(const char* label,
36 const sam3_result& full_r,
37 const sam3_result& vis_r) {
38 fprintf(stderr, "\n--- %s ---\n", label);
39 if (full_r.detections.size() != vis_r.detections.size()) {
40 fprintf(stderr, " FAIL: detection count mismatch: full=%zu visual=%zu\n",
41 full_r.detections.size(), vis_r.detections.size());
42 return false;
43 }
44 if (full_r.detections.empty()) {
45 fprintf(stderr, " WARN: both returned 0 detections\n");
46 return true;
47 }
48
49 bool ok = true;
50 for (size_t i = 0; i < full_r.detections.size(); ++i) {
51 const auto& fd = full_r.detections[i];
52 const auto& vd = vis_r.detections[i];
53
54 float iou = mask_iou(fd.mask, vd.mask);
55 int fg_full = count_fg(fd.mask);
56 int fg_vis = count_fg(vd.mask);
57 float score_diff = fabsf(fd.score - vd.score);
58 float iou_diff = fabsf(fd.iou_score - vd.iou_score);
59
60 fprintf(stderr, " det[%zu]: mask_iou=%.6f fg_full=%d fg_vis=%d "
61 "score_diff=%.6f iou_diff=%.6f\n",
62 i, iou, fg_full, fg_vis, score_diff, iou_diff);
63
64 if (iou < 0.999f) {
65 fprintf(stderr, " FAIL: mask IoU %.6f < 0.999 threshold\n", iou);
66 ok = false;
67 }
68 if (score_diff > 1e-4f) {
69 fprintf(stderr, " FAIL: score diff %.6f > 1e-4\n", score_diff);
70 ok = false;
71 }
72 }
73 fprintf(stderr, " %s\n", ok ? "PASS" : "FAIL");
74 return ok;
75}
76
77int main(int argc, char** argv) {
78 if (argc < 4) {

Callers 1

mainFunction · 0.85

Calls 2

count_fgFunction · 0.85
mask_iouFunction · 0.70

Tested by

no test coverage detected