TATraffic Analyzer

Technical report

What we built, what worked, what did not

One page, written for someone who wants to rebuild the system or decide what to fix next.

What we built

A detector-tracker-rules pipeline behind the official solution.detect_events interface. A fine-tuned YOLO finds road users and signal heads, ByteTrack links them into tracks, and a scene map of the junction is aligned to each clip with a SIFT homography. Ten per-class rule modules turn tracks and zones into time segments. A separate time-to-collision model scores accident risk for Part B. The same entry point backs the live demo. See the approach for the diagram and every rule.

Results on our dev labels

Scored with the unchanged evaluate.py against our own labels of the four sample clips (annotations/ground_truth.json, 80 events). Score A = 0.112 for predictions_samples.json. Micro F1 is 0.29 / 0.21 / 0.113 at IoU 0.3 / 0.5 / 0.7; ignoring labels it is 0.371 / 0.242 / 0.129. Part B cannot be scored here: the samples contain no accidents.

ClassF1 @0.3F1 @0.5F1 @0.7TPFPFN
stop_line0.5700.5700.290212
jaywalking0.5300.3400.15091223
solid_line_crossing0.1400.1400.140157
failure_to_yield0.0500.0500.05011026
near_miss000031
red_light000001
illegal_turn000004
illegal_u_turn000002
congestion000001

Ablations

Each step adds to the one above it; Score A on the same four clips.

ChangeScore ANote
Earlier pipeline: 0.5 FPS on CPU, 1.5 s merge gap0.049
+ 8 s merge gap for jaywalking0.062on the later preview run, 12 s gave 0.094 and 16 s 0.082 against 0.104, so 8 s stays
New rules at 2 FPS on every device (540p previews)0.070
+ stop reporting wrong_way and stopped_vehicle0.08543 and 10 false positives, 0 labelled events
+ resolution-scaled stop line, preview alignment, solid-line clearance, near-miss fix0.104
+ drop segments shorter than 1 s0.115F1 at IoU 0.7: 0.069 → 0.078
Final: same code on the 4K originals (predictions_samples.json)0.112

Frame rate, on C3905 with the earlier rules: 0.5 FPS scored 0.000 and 5 FPS 0.022. We now sample 2 FPS on every device, so CPU and GPU runs give the same events. Minimum segment length:

Minimum (s)Score AMean F1 @0.7
0.5000.1040.069
10.1150.078
1.5000.1170.080
20.1180.077
30.1190.078

We keep 1 s: longer minimums gain little and would delete genuine 1 s events such as red_light and short failure_to_yield crossings.

Error analysis

Of the 80 labelled events, 13 are matched at IoU 0.5, 23 are found but with boundaries too far off to match, and 44 have no same-class prediction at all. Jaywalking is mostly a boundary problem; failure_to_yield is mostly missed.

ClassMatchedBoundaries offMissed
jaywalking9194
failure_to_yield1323
solid_line_crossing116
stop_line202
illegal_turn004
illegal_u_turn002
congestion001
red_light001
near_miss001

Where the unmatched predictions fall. Most are the right class at the wrong time span; the main confusion is between pedestrian classes, since failure_to_yield and near_miss fire while someone is labelled as jaywalking.

Predicted classWhat it overlapsCount
jaywalkingright class, boundaries off11
failure_to_yieldright class, boundaries off3
failure_to_yieldoverlaps a labelled jaywalking3
failure_to_yieldnothing labelled there3
near_missoverlaps a labelled jaywalking3
solid_line_crossingright class, boundaries off2
otheroverlaps a different labelled class5
solid_line_crossingnothing labelled there1

Why the model reports 44 events against 80 labels. Label merging is not the cause: merging overlapping same-class labels only took our 84 raw labels to 80. Most of the gap is failure_to_yield, where the model finds 11 events against 27 labelled and covers 37 s of the 221 s we labelled. Jaywalking is seen about as much (731 s predicted, 685 s labelled) but in fewer, longer segments (median 18 s against 8.5 s), because the 8 s merge gap joins nearby pedestrians. Four labelled classes are never predicted, and the 1 s minimum drops 16 short segments.

Our labels start and end on whole seconds, so each boundary can be up to 0.5 s off while predictions are frame-exact. For short events such as a 2 s failure_to_yield, rounding alone can push a correct prediction below IoU 0.7. Per-clip mismatches are listed under Failure cases on each sample page.

What worked

What did not work, or not yet

What we would do next

  1. Have a second reviewer audit the four labelled clips, then tune thresholds against F1 at IoU 0.7.
  2. Calibrate Part B on real collision footage so 0.5 means “probably within 5 s”, and turn its high-risk pairs with box contact into accident events.
  3. Decode on the GPU (NVDEC) and batch the detector to widen the time margin.