The Evaluating Self

Improving an object detection model without training

Abhinav Gautam · 7 November 2026

We run a video management system for a client with a lot of yards and loading bays, and part of its job is counting the people and vehicles that show up on each camera. The counting is done by a stock YOLO model, and it had never seen one of these yards. It did a decent job most of the time, but the gaps were easy to spot once you looked. A truck parked with its back to the camera often got no box at all. On a quiet bay the count would flicker between numbers while nothing in the picture moved. And a truck painted in the client's own colours counted the same as any stranger's lorry, though telling them apart would be a useful thing to have.

The usual answer is to collect labelled pictures and train. We chose not to. Instead, working with LLMs on the analysis and the edits, we changed the model file directly: its weights, a few added operations in its graph, and the rules applied to its output.

What came of it

  • Trucks seen from behind. From the back, a truck looks a bit like a truck, a bit like a car and a bit like a bus, and the model splits its confidence three ways so that none of them clears the bar. We added seven small operations at the end of the graph that pool the five vehicle scores into one. That alone put boxes on 20 more vehicles across 230 frames, 18 of them real, without losing any (section).
  • Flickering counts. The count on a quiet camera used to change 55 times in ten minutes while nothing moved. A short memory on the counts, plus a rule for when the model draws a box inside another box, brought that down to 6 (section).
  • Parked trucks that scored too low. In a yard, a truck that scores 0.2 is still a truck. On twelve yard cameras we lowered the vehicle threshold from 0.28 to 0.12 and fenced off the few fixed objects the model mistakes for vehicles. On 404 frames that found 323 real vehicles against 40 false ones, a precision of 0.85 (section).
  • Steering, a little, and it shipped. We edited the model so it sees fewer trucks in the yard's clutter. An edit that nudged every box failed: real trucks went down with the false ones. What works is a gated nudge, which lowers the vehicle score only where one layer of the model looks like the yard's false objects. Held out by site it removes 11 of 48 false yard objects and loses none of 323 real trucks; over three nights it lost 5 real trucks among 1,650 night vehicle boxes, for 5 % more time. It is in the model the product runs. Five ways to go further all lost trucks or caught nothing (section).
  • People too far away. A person at the far end of a yard is a few pixels tall, too small for the model. Running it on the four quarters of the frame as well as the whole picks up about 70 more people across 230 frames, at five times the compute (section).
  • Vehicles from the same passes. Those quarter-frame passes now keep the vehicles they find too, at no extra cost. On the judged yard frames that counts 226 distinct real vehicles where the full frame alone counted 129. At night the quarters also see hoses and crates, so there a vehicle only a quarter found needs a score of 0.50 (section).
  • The client's own trucks. We gave the model a new class for the client's branded vehicles without training it, by fitting one direction in a feature space from 319 labelled crops. In the detector's own features it managed 0.83 on sites it had never seen, not good enough. In the image-search model's embedding space it reached 0.875, and that is what runs now: 26 of the top 29 tags were right when we checked live. A newer version, helped by two text descriptions, finds 89 % of branded vehicles on unseen sites and is going to the server. Further tries to put the brand inside the detector stopped short, because the detector was trained to ignore paint and the cameras at night record none (section).
  • Fire and spills. We fitted classes for both the same way. The fire one catches about a quarter of fires at zero false alarms on the site, which is not enough to ship, so it is parked. The spill one was fitted on the single spill in five days of footage and is waiting for a second spill to test on (fire, spill).
  • Making it faster. The two usual tricks both failed here. A smaller input was a third faster but lost a fifth of the vehicles. Eight-bit weights were slower and agreed with the original on only 60 % of frames (section).
  • Cameras that went bad. A separate check with no model in it tells when a camera has gone foggy, black, blocked, blurred or is showing colour bands, by comparing each frame's sharpness, brightness and edges against that camera's own normal. On its first night it raised 23 fog alarms, 18 of them real, and was right on all 4 colour-band alarms and the 1 black camera (section).
  • The browser. The same model also runs in the console's browser, and it turned out to be running on one thread because two security headers were missing. With them and two threads it is 10 to 18 % faster. Half-precision weights and a JavaScript tail were tried and did not help. The GPU path is wired up but needs a real GPU to measure, which the benchmark machine did not have (section).

Setup

The cameras cover weighing bridges, reception bays, loading docks, truck yards and gates. The system keeps one frame an hour per camera, the busiest moments as short clips, and runs the detector on those. It shows a person when the detector's score is 0.35 or more and a vehicle at 0.28 or more. A small harness runs the same file the same way on the stored frames, and every before and after below comes from it.

"Original model" below means the file as it shipped. "Edited model" means the same file after the changes described here. The other terms are collected beside the text. Figure 1 is one yard, before and after.

A weighing bridge at Site 6: four milk tankers and two trucks in a yard, seen from a high camera
A weighing bridge at Site 6: four milk tankers and two trucks in a yard, seen from a high camera
Figure 1. The weighing bridge at Site 6, 6 November, 15:02. Top, the original model at the product's cut-off of 0.28; bottom, the edited model in yard mode, cut-off 0.12, with the nested rule.

The original model draws four boxes on this frame. It has no box on the orange-cab tanker in the middle of the yard, where its score is 0.27, a hair under the cut-off. It has none on the small tanker beside the truck at the left, which scores 0.18, and none on the vehicle at the far end of the yard, at 0.12. The edited model in yard mode draws seven, one box per vehicle. The three it adds are the small tanker at 0.31, the middle tanker at 0.27 and the far vehicle at 0.19. The nested rule had nothing to drop on this frame.

Neither panel has a box on the blue open-body truck parked between the middle tanker and the one at the right, of which only the body shows. Seven of the eight vehicles, not all of them, and that is the shape of the whole post: each change is measured, adopted where it earns it, and the misses are written down. The sections take the problems one at a time.

Where the counts stood before any change

Before anything was edited, the first job was to pin down how the product's counts behaved, and whether a harness of my own reproduced them. It did on 82 % of frames. The 18 % it did not were boxes within a few hundredths of the cut-off, which said where the first gains would have to come from.

The model is a small YOLO detector, exported end to end. It takes a 640×640 letterbox on grey 114, planar RGB in [0,1], and gives one output output0 of shape [1,300,6]: x1, y1, x2, y2, score and class for each of 300 boxes. The product keeps class 0, people, at a score of 0.35 or more, and the five vehicle classes (1, 2, 3, 5 and 7) at 0.28 or more, with a minimum area and a cross-class dedup at IoU 0.7. The harness runs the file exactly so.

The protocol was 230 of the product's own stored frames from 117 cameras. The product's boxes were set against the harness's boxes, and a frame counted as agreeing when both counts matched.

Count agreement
82%
Boxes under 0.45
136of 538
CPU inference, median
74ms

The 18 % that disagreed were boxes at 0.28 to 0.40 flipping across the threshold on decode differences between the two paths. Nothing in the body of the network was at fault. So the first gains had to come from the last layer, and from what is done with its output.

How the detector works, and where we changed it

Before the fixes, a short tour of the model, because every fix below lands on a specific part of it.

What happens to a picture

The model looks at a picture once and hands back 300 candidate boxes. There is no second look. Everything happens in one pass, and that pass has four stages.

Resize. The camera frame is shrunk to fit a 640 by 640 square, with grey bars above and below. A 1280 by 720 frame ends up at half size. A person at the far end of a yard, already small, is now a dozen pixels tall. That one fact is behind the "people too far away" problem later.

Look. A long stack of filters, the backbone, turns the picture into three grids: a fine one where each cell covers 8 pixels of the picture, a middle one at 16 pixels, and a coarse one at 32. Each cell no longer holds colours. It holds a few hundred numbers that describe what is around that spot: edges, textures, parts of things. Small objects show up on the fine grid, a tanker that fills a quarter of the frame on the coarse one. A short stage called the neck then lets the three grids share notes, so a fine cell knows it is sitting on a truck and a coarse cell knows where the truck's edges are.

Guess. At every cell of every grid, 8,400 cells in all, the head makes one guess. One small branch says where the box is: how far the object's left, top, right and bottom edges are from the cell. The other branch says what it is: it boils the cell's description down to 128 numbers, then multiplies them by one row of 128 weights per class to get a score for each of the 80 classes the model knows. Each score goes through its own squashing function, so the 80 scores are independent of each other. A cell can be 0.26 truck and 0.03 car at the same time. That independence is what the first fix uses.

Rank. Each cell keeps only its best class and that class's score. The 300 cells with the highest scores win, and their boxes, scores and classes are the output. The product then draws a box when the score is at least 0.35 for a person or 0.28 for a vehicle.

One more thing worth knowing: this model was trained so that one cell claims each object, instead of a cluster of neighbouring cells all claiming it. So the usual step of thinning out duplicate boxes is not in the file. The duplicates it still makes are different in kind, a cab and the whole truck boxed separately, or one box round two trucks, and those are what the "flickering counts" section deals with.

picture640 × 640lookbackbone + neck:three grids, cellsof 8, 16 and 32 pxguessat every cell,a box and80 scoresrankbest classper cell,keep the top 300decidecut-off, dedup,per-camera rules(server)1234561input size2new brand, fire or spill row3steer one head layer4merge the 5 vehicle scores5dedup + nested, in the file6cut-off, zones, tiling
Figure 2. One pass of the detector, left to right, and the server's decision step after it. The numbered marks show where each change in this post acts.

Where each change lives

ChangeWhere it actsWhat is editedSection
Vehicle mergeTail, after /model.23/Sigmoid and before ReduceMaxSeven nodes added and three constant maskss1
Brand, fire and spill rowsClass head: a 1×1 Conv over the 128-channel feature, pooled, concatenated to the 80 logitsNodes added; one weight of [1,128,1,1] per level, fitted in closed form; three constants widened to 81s5, s6, s7
Steering, first attemptRows 1, 2, 3, 5 and 7 of one2one_cv3.{l}.2Weights onlys3
Steering, gated (shipped)A head convolution's pre-activation per level: pooled projection, gated, subtracted from the five vehicle logitsFifteen nodes added, with directions fitted in closed form; deployeds3, and below
Dedup and nested rule in the graphAfter TopK, on the [1,300,6] rowsNodes added; output contract unchanged; built, not deployeds2
Tracks, hold, per-camera cut-off, ignore zones, tilingOutside the file, in the serverRules and per-camera settings; no weight or nodes2, s3, s4
Input sizeThe input shape, two baked reshapes, Constant_12, 13 and 14Constantss8
INT8Every weightWeights, quantiseds8

Where each change of this post sits, and what kind of thing it changes.

Why almost every change is at the end

The "look" stage is shared by all 80 classes. Every number in it feeds the person score as much as the truck score, so changing anything there moves everything, and we were not willing to move the people counts. The "guess" stage is different. The score for a class is just 128 numbers multiplied by 128 weights. That is simple enough to reason about: a new class is a new row of 128 weights, which can be worked out from labelled examples with a formula instead of training, and merging five classes is arithmetic on five scores. Those are the kinds of edits you can write down, test on frames, and undo.

We also checked whether an earlier stage would have been better, as part of the steering work. We fitted a simple separator between the yard's false boxes and real low-scoring trucks at every point in the network, from the backbone outputs through the neck to each layer of the head, testing on sites it had not seen. Nowhere did it get good. The best point reached about 0.86 on a scale where 1 is perfect, and on the fine grid, where most false boxes live, nothing beat 0.76, with the early stages worse than the head. The false boxes are not hiding in an early layer waiting to be found. The one thing that helped was a gated nudge at one head layer, which removed 11 of 48 false boxes without losing a real truck on sites it had not seen, and it now ships. So the edits sit at the end because that is where the signal is, not out of habit.

Trucks seen from behind were missed

A truck parked with its back to the camera was often not counted. In frame 45 at Site 2 a pickup stood rear-on in the yard and the product drew nothing on it. Merging the five vehicle classes into one score, with seven nodes added after the last layer, put a box on it and nineteen more across the 230 baseline frames, eighteen of them real by eye, with none lost and the people counts unchanged.

The model does this because it was trained to tell car from truck from bus, and a rear view carries little of what separates them. Its evidence spreads over several of those classes instead of landing on one. The pickup scored 0.26 as truck and 0.03 as car. The product takes the best class, 0.26, against a cut-off of 0.28, and so it draws nothing. The vote is split, not absent.

A small truck seen from behind, parked rear-on in a yard
Figure 3. The pickup in frame 45 at Site 2, and the five vehicle-class scores of the original model at its anchor, read from /model.23/Sigmoid_output_0. The toggle shows the original model, the edited model, and yard mode on the same frame.

The bars are the scores at anchor 7022, the one the edited model reported the box from, and the one score they become. The original model has no box here at 0.28; the edited model has one at 0.28 exactly. The vehicle in front of the pickup scores 0.12 with the original model and 0.22 with the edited one, under the product's cut-off either way, so it appears only under yard mode, the third setting of the toggle.

Where the scores come from

At each pyramid level the class logits come from a 1×1 convolution, model.23.one2one_cv3.{l}.2, with weight [80,128,1,1]. Reshape_3..5 and Concat_1 lay the three levels out as [1,80,8400], and /model.23/Sigmoid turns the logits into scores. Concat_3 joins them to the decoded boxes. Then Transpose → Split [4,80] → ReduceMax → TopK(300) → GatherElements → TopK keeps the 300 anchors with the largest best-class score. That ReduceMax is where the split vote is lost.

The fix: one vehicle score from five rows

The edit replaces the truck row with the chance that the anchor is a vehicle of any of the five kinds, and zeroes the other four rows.

p7 := 1 − ∏c ∈ {1,2,3,5,7} (1 − pc), p1, p2, p3, p5 := 0

Seven nodes go in directly after the sigmoid. surgery/Gather takes the five rows by surgery/vehicle_idx. Sub, ReduceProd over axis 1 and a second Sub give 1 − ∏(1 − p). MulInto places that on row 7 through the one-hot initializer surgery/into_mask. MulKeep multiplies the original tensor by surgery/keep_mask, which is zero on the five rows, and Add joins the two. Every consumer of the sigmoid is re-pointed to the result, so the top-300 ranks anchors by the merged score. Nothing else changes, and the output contract holds.

Figure 4. The tail of the export. Outlined nodes are the inserted ones.

A noisy-OR rather than a max, because a max cannot raise any score, and three weak votes for classes that are near-independent on a truck rear should add up. The other four rows are zeroed rather than left, because the product drops a vehicle box that overlaps a vehicle of another class at IoU above 0.7, and with those rows at zero no such pair exists.

Measured

The edited file was run on the 230 baseline frames, then on 346 daylight yard frames from four sites. Every new box was judged by eye from a crop sheet.

Vehicle boxes on the 230 frames went from 233 to 254. None were lost, the people counts did not change, and latency did not move. Eighteen of the twenty new boxes were real by eye; the two doubtful ones were a sliver at Site 3 and a wall at Site 1. On the yard frames the merge gained 17 distinct vehicles, 16 of them real. Adopted, and this is the file the product fetches.

What it does not fix is a vehicle whose evidence is weak on every row. The vehicle in front of the pickup in Figure 3 still scores 0.22, under the cut-off, and that is the problem the yard cut-off takes up below.

Counts that flickered, and one truck counted three times

On a quiet camera at Site 4 the people count changed 15.9 times a minute, and 55 times in ten minutes it jumped away and back within a second. The product counted boxes per frame, so every box that crossed the cut-off one way and then the other changed the count. A decision layer that turns boxes into tracks, with hysteresis and a short hold, brought that to 6.9 changes a minute and 6 blips, with no ground truth needed to see it. A second rule, for boxes nested inside other boxes, stopped one truck being counted as three.

The flicker is in the scores, not the scene. A person who does not move still gets a different score on each frame as the compression noise changes, and a score that hovers near 0.35 crosses it often. A count made of single frames has no memory, so it follows every crossing.

The fix: tracks with hysteresis and a hold

The decision layer turns a camera's per-frame boxes into tracks. A track is born from a box at the product threshold, enter. It is kept by boxes down to keep = 0.20, counted only after min_hits = 2 sightings, and held for hold_s = 1.5 s after the last one. Boxes are associated to tracks greedily by IoU within a kind, at 0.3. Before association, same-kind duplicates are dropped at dedup_iou.

The dedup thresholds come from the data. On the quiet camera, 46 of 55 overlapping person pairs at IoU of 0.9 or more were one person boxed twice. On a crowded bay, pairs at 0.5 to 0.85 were different people sitting together. Nested boxes of one truck overlapped down to about 0.8. So the threshold is 0.9 for people and 0.7 for vehicles. At 0.7 for people the quiet camera gave 5.8 changes a minute and 7 blips; at 0.9 it gave 6.9 and 6, and the busy bay kept its real neighbours, which is the trade worth making.

Measured

The measurement is two ten-minute daytime clips at 2 fps, with no ground truth, by two flicker measures: changes per minute of the count, and blips, excursions that return within one second. Figure 5 replays the quiet camera with both counts side by side.

What the product counted
0
15.9 changes/min · 55 blips
What the layer counts
0
6.9 changes/min · 6 blips
raw per-frame countdecided count
Figure 5. People on 1,201 frames of one quiet camera at Site 4, 16:30 to 16:40 on 4 November, replayed from the cached detections at 60× speed. The two measures accumulate as it plays.

The table has the same two measures for the quiet camera and for a busy loading bay with up to thirteen people in view.

People count, 10 min at 2 fpsChanges/min rawdecidedBlips rawdecided
Quiet camera, Site 4 ch515.96.9556
Busy loading bay, Site 5 ch4, up to 13 people46.230.013256

Count flicker on two ten-minute clips, raw per-frame count against the decision layer.

The busy bay still flickers at 30 changes a minute. The layer does not fix a bay where people really do come and go every few seconds; it only removes the changes the scene did not make.

One truck boxed three times: the nested rule

The merged model boxes a tanker and also its cab, or draws a group box round a tanker and the van beside it, and each extra box was a vehicle in the count. The nested rule drops the boxes that are parts or groups of other boxes. With contained(a, b) the fraction of a's area inside b, a box b is dropped in two cases.

part: contained(b, s) ≥ 0.8 for some stronger s
group: ≥ 2 members m with contained(m, b) ≥ 0.8, pairwise apart, all stronger than b or each ≥ 0.15 of b's area

A part inside a group box is not a part, since the group box is the one that goes. On the yard clips the rule fixed 118 wrong frames and left about 52. The ones left are mostly cab and rear boxes that are under 80 % inside anything, which the rule cannot tell from two vehicles close together. Figure 6 lets you try the three cases.

Figure 6. The rule on three cases, recomputed as you drag. A dashed box is one it drops.

The same rules as nodes in the graph

Dedup and the nested rule are code today, copied into the server, the browser and the SDK, which is three places for one rule to drift. So the same two rules were also built as a stage in the graph, after the top-300, and checked box for box against the Python version on 12,770 frames. It is built and not yet deployed.

bake_postprocess appends the stage on the [1,300,6] rows. Split separates boxes, score and class. Pairwise intersections over [300,300] come from broadcast Min, Max, Sub and Mul, and containment is intersection over area. Kind masks come from Equal and Or. A row is inside another when containment is 0.8 or more, both are vehicles, and it is off the diagonal. The group test is a MatMul of the member mask with the apart mask, then ReduceMax above 0.5. A part is a row inside a stronger non-group row. A Where zeroes the dropped scores.

Then NonMaxSuppression runs per kind on the survivors, at 0.9 for people and 0.7 for vehicles, because greedy NMS is a recurrence and not a pairwise test. output0 stays [1,300,6], and a dropped row keeps its place with score 0, so the contract holds. Opset stays 12.

On the 12,770 frames, 6,938 stored frames and 5,832 daylight clip frames, 0 frames differ from the Python pipeline box for box. The stage costs 1 ms per frame single-threaded, 1.5 ms on its own, and is within noise at four threads.

Parked trucks in the yards scored under the cut-off

With the merge in, the yards still missed trucks. Box-truck rears and sides, pickups and a milk van sat at scores of 0.10 to 0.28, under the product's single cut-off of 0.28. On 346 yard frames that band held 811 boxes, 72 distinct objects, about 60 of them real against about 6 false. Lowering the cut-off per camera, on the twelve cameras where that band is mostly trucks, and fencing the fixed objects with ignore zones, finds those trucks at a precision of 0.85 over a 404-frame rerun.

The model is not wrong about these trucks, only unsure. A truck half hidden by another, or seen side-on across a yard, gets a score the product's one threshold throws away. The same band on a camera that looks at a wall or a crate stack is mostly noise, which is why the cut-off cannot simply be lowered everywhere.

The fix: a cut-off per camera

The fix is not a weight but the product's threshold. Yard mode is a per-camera setting: vehicle.enter = 0.12 with the nested rule, keep = 0.08, and hold_s = 30 so a parked truck is not lost when its score dips for a frame.

Which cameras get it was decided from the frames. The protocol was 436 daylight frames, 07:00 to 17:00 device time on 5 November, over 104 cameras, with the edited model at vehicle_t = 0.10 and the nested rule. Boxes at 0.10 ≤ score < 0.28 were collapsed per camera at IoU above 0.6 across frames into distinct objects. Every camera with three or more distinct gained objects was judged by eye from crop sheets: each object real, a second box on a counted vehicle, or not a vehicle. Yard mode goes on where precision is 0.75 or more and at least three objects are real.

Band precision over the 31 judged cameras was 0.61, 124 real of 203; on the true yards it ran from 0.75 to 0.92. What dragged it down was fixed objects: the same window or crate stack re-found on every frame.

Ignore zones round the fixed offenders

Eight ignore zones in sites/zones.json, as normalised x, y, w and h, were drawn only round fixed offenders: a window above a bay, crate stacks, a hose on a bay floor, and wall and floor slivers at the frame edge. A vehicle box centred inside one never counts. None was drawn where trucks park, and one candidate at Site 9 ch8 was dropped because the object sits beside a parked pickup. On the 14 candidate cameras the zones took false distinct objects from 11 to 3.

A rerun with 12 to 46 frames per camera, 404 frames in all, gave a precision of 0.85, 323 real against 40 false. It moved two verdicts off, Site 10 ch5 and Site 11 ch1, and one on, Site 1 ch4. Figure 7 has the per-camera picture, and the fold-out under it the full table.

precision before zonesafter zones404-frame rerunfalse objects per day, rerun
Figure 7. The 14 candidate cameras: precision of the gained boxes before and after zones, the rerun, and false objects per day. Bold cameras are on after the rerun.

Precision here is real gained objects over all gained objects in the band. False per day assumes ten looks an hour over ten daylight hours, and that every look re-finds a fixed offender, which is what a fixed offender does.

All 31 judged cameras
CameraFramesGainedRealDupFalsePrecision, before → after zonesFalse/day, before → afterRerun precision (frames)Yard mode
Two stainless milk tankers and a decorated white truck at a raw milk reception bay
Figure 8. Raw milk reception at Site 6 ch2, 5 November, 15:39, a camera where yard mode is on. Toggle between the original model, the edited model at 0.28, and yard mode.

Three things that did not replace the zones

Zones are drawn by hand, so three automatic alternatives were tried in their place: steering the vehicle logit inside the model, a two-look rule on the gained boxes, and a check of each gained crop against text prompts. None did the job, and one found a smaller use.

Steering first. The class head's last convolution is a 128-to-80 matrix per level, so if some of the 128 channels fire on false boxes and not on real trucks, their entries in the five vehicle rows can be damped and the false boxes should fall. An LDA direction was fitted per level on the head features of the judged real and false objects, held out by site, and the k channels that lean most to false had their entries in the five vehicle rows multiplied by a factor f, with the merged file otherwise unchanged. The measurement was every daylight frame of the 14 candidate cameras plus 230 night frames, 999 in all.

The mildest variants, damp-lda-K4 at f = 0.5 and 0.0, removed 0 and 4 of 48 false objects and lost 5 and 7 of the 323 real ones. The variants that removed more, damp-contrib at K4 and K8, which rank channels by their contribution to the vehicle logits, removed 24 to 36 of 48 and lost 71 to 158 of the 323. No setting removes a false box without losing real trucks. The false boxes are not a direction in the head features; they are particular objects on particular cameras, which is what a zone is. Rejected in this form; a gated version, further down, did better.

The second was a two-look rule, simulated on 699 clip frames of six cameras: a gained box counts only if a vehicle box of 0.10 or more in the frame ten seconds earlier matches it at IoU of 0.3 or more. It removed 80 of 319 false boxes and 238 of 1,398 real ones, and 10 of 23 false distinct objects against 54 of 129 real. A static offender is there ten seconds earlier too, so it survives. Rejected as a substitute for zones.

The third was the search model with text. Each crop's embedding is scored against a set of vehicle prompts and a set of non-vehicle prompts, among them crate stack, sign board, wall, window, hose, caption text and hand cart, by the softmax mass on the vehicle prompts. On the 182 judged boxes of the first day it separates real from false at an AUROC of 0.86, where the detector's own score manages 0.64. At a threshold that keeps 98 % of the real boxes it removes 12 of 58 false ones. On the 363-box rerun the AUROC falls to 0.78 and it removes 7 of 40.

Against the zones it loses. On the 14 yard cameras the prompts remove 2 to 5 of 11 false boxes and lose 1 to 3 real trucks; the zones remove 8 and lose none, and zones plus prompts add at most one removal. The one-day threshold keeps only 92 to 93 % of the rerun's real boxes. Below about 100 px, where most of the band sits, the crop says nothing to the model. Each crop costs 40 ms on the quantised tower on an idle CPU, so a frame with two to eight weak boxes costs 80 to 320 ms, two to four detector passes. Rejected as a per-frame gate.

It is kept for one offline job: ranking a new camera's gained clusters for a person to judge when drawing its zones. Its average precision for finding the false ones is 0.71 to 0.77, against 0.44 for the detector score.

A gated edit that did ship

The first steering attempt nudged every box, and a real truck and a crate stack share enough of their internal numbers that every nudge moved both. The second attempt adds a gate. On each of the three grids it watches one layer of the class head, averages that layer's pattern over a small window round each spot, and measures how much it looks like the yard's false objects. Below a threshold, set so that 95 to 99 % of the real trucks it was fitted on stay under it, nothing happens. Above it, the vehicle score is pushed down in proportion. The person score is not touched.

It is fifteen operations added to the file, fitted from the judged boxes with a formula, and it is in the model the product now runs. Held out by site, it removes 11 of the 48 false yard objects and loses none of the 323 real trucks. The ignore zones remove 8, five of them the same, and together they remove 14. Before it shipped we checked where it could do harm: three full nights and the daytime cameras outside the yards, with every lost box looked at by eye.

Frames checkedFramesVehicle boxesReal trucks lost
Night, 4 to 5 November2302410
Night, 5 to 6 November8686854
Night, 6 to 7 November8747241
Daytime, cameras outside the yards3302841

Real trucks the gated edit pushed under the cut-off, judged by eye. People counts were the same on all 2,302 frames.

The four on the second night are two trucks, each seen in two hourly frames, that scored 0.29 to 0.32 and fell to 0.22 to 0.27. Six parked motorbikes and bicycles went the same way over the three nights. Most of the rest of what it dropped at night was caption text, crates and hoses, the things it was built to remove. It costs about 5 % more time per frame.

What it removes are the marginal false objects: the six it adds to the zones are single boxes that scored 0.10 to 0.20. What it leaves are the entrenched ones, signs, crate stacks, openings and walls that the model scores 0.28 to 0.66 on every look. Those stay with the zones.

What did not take it further

One gate per kind of false object. By eye the false objects are nine kinds: signs, crate stacks, captions, walls, openings, machinery and so on. A gate per kind looked like the answer in sample, removing 13 to 17 of 48 with no truck lost. But each kind has only 3 to 10 examples, and a gate fitted on so few memorises them. Held out by site, the gates removed 11 to 15 and lost 5 to 6 real trucks, where the single gate removes 11 and loses none.

A lift for faint trucks. The same kind of gate, turned round, raised the score of faint real trucks. It put 27 of the 323 real yard trucks over the cut-off, but it raised every part of a truck as well, cabs, roofs and wheels, about 70 extra boxes on trucks already counted. The nested rule then read 9 whole-truck boxes as groups of parts and dropped them.

Matching boxes against the background. A box whose pixels match the camera's background, the median of its hourly frames over several days, should be a fixed object. But in these yards a truck stays parked for 12 to 63 hours, so parked trucks are the background too. At a setting that keeps 99.5 % of real boxes, the rule removed 2 more false objects than the zones and the gate, and lost 3 parked trucks.

Hand-built texture filters for crates. We added 27 fixed measures to the file at each spot: how much the pattern repeats, how flat it is, a dark round wheel cue, and colour. On their own they caught none of the 7 crate stacks among the judged false objects. Added to the head's own pattern, they caught 3 to 5 more of the 95 false objects, none of them crates, for about 20 % more time.

A curved boundary instead of a straight one. A fixed layer of 2,048 random combinations of the head's numbers, with only the output weights worked out by formula, can draw a boundary a single direction cannot. Held out by site its separation score on the yard objects was 0.696 to 0.718, against 0.735 for the plain direction.

The reason is the same each time. At no layer of the network, from the backbone to the head, does a crate stack sit apart from a faint truck: the best separation score held out by site is 0.82 to 0.86. An edit can take the false objects at the weak edge of that overlap, and no more.

People far from the camera were too small to find

A person at the far end of a yard is a handful of pixels tall once the frame is letterboxed to 640, and the detector does not see them. Running the detector again on the four quarters of the frame, so that each far-off person is twice the size, found about 70 more real people on the 230 baseline frames, at the cost of five passes instead of one. It is adopted on the server, where five passes are affordable.

The model does not fail here because of anything in its weights. A 640×640 letterbox of a 1280×720 frame halves everything, and the finest grid the head looks at has 8-pixel cells, so a person a dozen pixels tall covers one or two of them. Give the head a bigger picture of the same person and it finds them.

The fix: tiling

detect_tiled runs the full frame plus a 2×2 grid of crops with 15 % overlap, each letterboxed to 640, and merges the passes. Boxes from different passes that overlap at IoU of 0.5 or more, or that are 70 % contained in a kept box, are one box, and the higher score is kept. At first the tiles contributed people only, because their vehicles were often fragments of trucks the full frame already had whole. A better merge changed that, below.

What it does not fix is the browser's live view, where five passes are too slow; there the full frame alone runs.

Vehicles from the same passes

The server already ran the four quarter-frame passes for people and threw their vehicles away. It now keeps them, at no extra cost. The merge is careful with the full frame: a full-frame vehicle box is always kept as it is. If a quarter sees the same vehicle with a higher score, the full-frame box takes that score. A quarter's box is added only when no full-frame box matches it.

On the 404 judged yard frames, at the product's cut-off of 0.28, that counts 226 distinct real vehicles where the full frame alone counted 129, for 16 false objects instead of 5. It loses 13 of the 1,290 boxes the product drew before, 1 %, all real trucks: a stronger box from a quarter makes the nested rule read the full-frame box as part of another truck.

At night the quarters also find hoses, crate stacks and lit signs. On the 230 night frames, the boxes the quarters added were 16 real and 18 false. So between 18:00 and 06:00 on the camera's clock, a vehicle only a quarter found needs a score of 0.50, and the added boxes become 10 real and 3 false. The floor does not touch full-frame boxes whose score a quarter raised, and 18 false ones of that kind remain at night.

Passes, judged yard framesDistinct realDistinct falseProduct boxes lostTime
Full frame only12951×
Full frame + four quarters, vehicles kept (adopted)2261613no extra
Full frame + top-centre quarter (measured)197841.9×

Vehicles at the cut-off of 0.28 on the 404 judged yard frames, out of 1,290 product boxes.

Cameras that do not tile would need the extra passes paid for. A cheaper version for them adds one pass on the top-centre quarter of the frame, where the far end of a yard usually is. It reaches 197 distinct real vehicles for 8 false and 4 product boxes lost, at 1.9 times the time. It was measured and not adopted.

The client's own trucks looked like any other vehicle

The client's own trucks carry its brand, a blue-and-white paint scheme with the logo, and the client wanted them counted apart from everyone else's. The detector has no such class and cannot be taught one. What shipped is a prototype in the search model's space, one dot product on a vector the server already has, which tags branded box trucks: in the live check it tagged 391 of 857 vehicle crops, with about 26 of the top 29 right by eye. Held out by site it is right 0.875 of the time, and most of what it misses is at night or small.

The detector cannot do this on its own because its head was trained to separate truck from bus, not one paint from another, and the channels that fire on a blue cab fire on an orange one too. What still works is the premise that a brand is one direction in a frozen feature space, fitted in closed form from labelled crops and applied as one dot product. Two spaces were tried: the detector's own head features, and the search model's.

First try: a brand row in the detector's own features

The class-head feature at each level is the tensor that feeds model.23.one2one_cv3.{l}.2, 128 channels. The brand row is a second 1×1 Conv over it, surgery/Row{l} with weight [1,128,1,1], followed by an AveragePool, surgery/Pool{l}: 3×3 at stride 16, 7×7 at stride 32, pads w//2, count_include_pad 0. A single cell's feature was at chance; the pooled one was not, because a brand is the whole box, not one cell. The margin is concatenated to the 80 logits before each level's reshape, and Constant_3, Constant_16, Constant_19 and the Split widths move to 81.

The first version Sliced the truck logit out of the conv output and Added it to the margin. That can lift a weak fragment of a branded truck above the product's floor, and on one test frame it added fragment boxes. The version that stands is a relabel. The row is scaled by 20 so that after the sigmoid row 80 holds a gate, and ten nodes, surgery/Relabel*, split the vehicle score by it. No box can score more than the edited model gave it.

m = w · meanw×w(f) + b, g = σ(20 m), p80 := p7 g, p7 := p7 (1 − g)

The row is fitted per level by LDA with shrinkage on the pooled features of labelled crops, with b at the midpoint of the two class means and the whole scaled so a typical box sits a fixed margin from zero.

w = (C + λ tr(C)/128 · I)−1 (μbrand − μother), λ = 1

The labels are 319 daylight crops from 16 sites, 115 branded and 204 other. Infrared crops were excluded, and ten labels were corrected after error sheets. Figure 9 shows which of the 128 channels the fitted direction leans on.

Figure 9. The 128 weights of the stride-32 brand direction with the 7×7 window, the ten largest highlighted, and below them the pooled feature of one branded truck and one tanker on those channels.

The direction in Figure 9 was refitted on the 115 crops that score at that level. In the lower panel each cell is shaded by its contribution w·f, and the two margins are the sums.

Held out by site, the row reached 0.805 at stride 16 with the 3×3 window on 174 crops, and 0.826 at stride 32 with 7×7 on 115 crops, 0.81 to 0.83 overall. Mid-depth and neck features did no better. The errors are coloured-cab tankers tagged as branded, night crops, and slivers. The target was 0.9 or better held out, so the row is not deployed.

What shipped: a prototype in the search model's space

Every box the product stores is already embedded by the cutout search: the image tower of a CLIP ViT-B/32, 512 dimensions, unit length, on the crop padded square with the model's mean colour. The same LDA with λ = 1 on those embeddings gives a 512-d unit direction and an offset of −0.039, with the threshold at 0, fitted on all 319 crops with the quantised vision model and an 8 % box margin. That is the artefact the server loads. A tag costs one dot product on a vector it has anyway.

the client's brandother vehicleshover or tap a point for the crop, its site and its prototype margin
Figure 10. The 319 labelled crops in the 512-d space, reduced to its first two principal components (25 % of the variance). The prototype's direction is not one of these two axes, so some overlap here is expected.
A blue-cab milk tanker beside a sampling platform, seen from above

Site 7 ch7, in yard mode. The tanker's box is a vehicle and is not tagged: margin -0.10.

A dispatch bay at Site 1: a box truck in the client

Site 1 ch4, 5 November, 13:00, in yard mode. The box truck in the client's brand (0.94) is tagged, margin +0.08; the tanker in front of it (0.89) is not, margin -0.08.

Both cameras run yard mode in the product, so that is the view each figure opens on, with the original model and the edited model at 0.28 on the toggle for comparison. At Site 7 ch7 yard mode boxes the trucks at the far end of the yard, which score 0.20 to 0.36 and are cut off at 0.28. At Site 1 ch4 the original and the edited model find the same two boxes at 0.28, and yard mode adds the truck at the left edge at 0.23 and the second blue box truck behind the tagged one at 0.21, partly hidden by it; both get a margin of +0.01, just over the line.

The prototype was scored held out by site in four variants, with the shipped one in the third row.

Prototype, held out by siteAccuracyFalseMissed
fp32 vision model, tight box0.906624
fp32, daylight crops only (saturation ≥ 40, n 110)0.855
quantised, 8 % margin (shipped)0.8751426
CLIP + stride-16 head feature, level 2 only (n 115)0.97403

Brand prototypes held out by site, on the 319 labelled crops.

Fifteen of the misses are night crops with saturation under 40. The combined row in the last line is better, but it needs the detector's feature taps at ingest, which the server does not output today. The live check after deployment tagged 391 of 857 vehicle crops, with about 26 of the top 29 right by eye. Adopted.

What it does not fix: held out, a clearly branded vehicle is still missed about a quarter of the time, mostly at night and on small crops. A refit for the tankers that carry only the logo is written up in docs/brand.md of the model repo and was not shipped. An unmarked tanker is by definition not brand, and is not tagged.

A wider definition and a better prototype

We then settled what counts as the client's: any vehicle that clearly carries the brand, which takes in blue cabs with the logo, striped pickups and "MILK VAN" vans as well as the box trucks. A silver tanker with no logo is a plain vehicle. Relabelled that way the set is 358 crops from 16 sites, 150 branded and 208 other.

On that set the single direction finds 0.753 of the branded vehicles on unseen sites, with 19 false tags among the 208 others. Adding a score from two text descriptions, "a blue and white dairy truck" and "a blue truck cab with a dairy logo", set against "a silver milk tanker" and "an orange truck", lifts that to 0.893 for 25 false. That fused prototype is the one going to the server.

Trying again inside the detector

The browser and the SDK cannot run the search model, so we tried once more to put the brand in the detector file. The head's own pattern alone has a separation score of 0.82 between branded and other vehicles. Fixed colour filters added to the file lift it to 0.85, and to 0.88 in daylight. But 87 of the 150 branded crops are night frames, and at night these cameras switch to greyscale infrared, so there is no colour to measure. A greyscale pattern and a brightness profile of the vehicle under infrared brought the night score from 0.75 to 0.80.

Two other routes did no better. An open-vocabulary detector, which takes its classes as text, scored 0.69 on the brand, and as a vehicle detector it kept only 220 of the 363 real yard trucks. A curved boundary from a random layer scored 0.760 against 0.751 for the straight one. The fused prototype scores 0.95 on the same scale.

The reason is plain. The detector was trained to find a truck whatever its paint, so its features carry little of the paint, and at night the camera does not record it. The brand stays with the image-search model on the server.

A live tag for the browser anyway

The live view in the browser had no brand tag at all, and the server only looks at each camera every one to five minutes, too slowly to feed it. So the best of the in-file attempts went into the browser's copy of the model as a first version: the colour row by day, the head's own pattern at night, and a switch between them that reads how colourful the whole frame is.

It costs nothing measurable, 0.3 % of a frame's time. On sites it never saw, it tags 96 of the 150 branded vehicles, and it wrongly tags 36 of the 208 others, about one in six. The weak part is the switch: whole-frame colour agrees with the vehicle's own colour only 69 % of the time, so a lit yard at night or a dull afternoon gets the wrong row. The stored events keep the server's tag, which finds 134 of the 150 for 25 false.

Fire and smoke were not among the classes

A fire alarm from the same cameras would be useful at a site like this, and the detector has no class for fire or smoke. A row for it was fitted in closed form, with no training, from two public picture sets, with the site's own frames as negatives. At the rule set for it, no false alarm on the site, it sees about a quarter of the held-out fires. That is not enough to ship, so it is parked.

The detector's head features do carry something of flame and smoke, bright warm texture with soft edges, but nothing in the model was ever asked to separate that from a sodium lamp or a sunlit wall. A direction fitted from a few hundred pictures gets the large, plain fires and little else.

The fix tried: a row with no base class

It is the same row mechanism as the brand row, with no base class (on_top_of=None): class 80's logit is the pooled margin alone, so the row can create boxes of its own. The positives are the window-mean head feature at the centre of labelled fire and smoke boxes from two public picture sets, taken at the level whose stride fits the box, with a window of 5. The negatives are the pictures' non-fire cells and every step-th cell (3, 2 and 1 per level) of 353 of the site's own frames. The direction is the same LDA as the brand row.

cut = quantile1−10−4(w · fother), b = −cut, rowl = (s·w, s·b, 5)

The cut-off sits at the 1 − 10−4 quantile of the other cells because a frame has 8,400 of them, so even that rate is near one false cell per frame. Build B added hard negatives: all cells of night and infrared frames, with mean brightness under 90 or grey, plus bright warm cells, with window mean above 0.55 and R − B above 0.08. They were repeated three times in the fit and given their own cut-off above every one of them.

Measured

Three builds were scored on the two held-out picture sets, A and B, and on 367 of the site's own frames that the fit never saw.

BuildHeld-out images with fire found (set A / set B)Unseen site frames with an alarm
A: levels 0, 1, 2, window 5, cut at 10−40.515 / 0.2791 of 367
B: A + hard negatives ×30.501 / 0.2422 of 367
C: level 2 only, cut above every site cell0.2720

Three fire-row builds: the share of held-out fire pictures found, and alarms on 367 unseen site frames.

Hard negatives did not help. The one alarm on an unseen frame was a sodium lamp at Site 8 ch7, at 0.52. By eye the row lights up most of a large fire and misses small ones, and at the owner's rule of no false alarm on the site it sees a quarter of the held-out fires.

What it does not fix is the lamp. A flicker rule in the decision layer is meant to catch it, on the grounds that a lamp is static and a flame is not, but it has not been tested on real fire video.

alarm at frame t  if  a class-80 box is present on the last 5 frames (IoU ≥ 0.2 chain)
                  and  (centre moved ≥ 0.25 of its size  or  width or height changed ≥ 0.25
                        or  score ranged ≥ 0.15)      # a lamp is static; a flame is not

The row is parked, not deployed.

A spill on a pad that nothing was watching for

From 14:05 to 14:28 on 4 November an opaque white stream ran from the tanker pad edge at Site 6 ch2 into the mud, and nothing in the system saw it. It was the one such event in five days of frames. A scanner that looks for pale, smooth, new regions on the floor was already running over every stored frame, and it did not score the spill; the event was found by eye on the scanner's review sheet. A spill row fitted on the first half of the event finds 0.915 of its second half with 2 alarms on 412 unseen frames. It has seen one spill, so it waits.

The detector has no class for liquid on a floor, and the scanner missed the stream for a plainer reason: at the scanner's 320-px working resolution the stream is two pixels wide, under the smallest blob it will count. What the scanner scored on that frame instead was the tanker's steel body, which no box masked because clip frames carry no detector boxes.

The reception bay with a tanker on the pad; a thin white stream runs from the pad edge into the mud
Figure 11. The spill frame, 14:12. The dashed box is the hand-drawn label the spill row was fitted on; the solid boxes are the detector's.

The scanner

The scanner uses no model. vmsdetect.spill runs per camera over every frame on disk, hourly frames and clip frames alike, at 320×180, and asks whether a pale, smooth, new region lies on the floor. It works in five steps.

  1. Background. The floor zone is the lower 67 % of the picture. From the camera's other frames (other hours and other clips, never the same clip, which shows the same puddle; at most 150 frames per camera, thinned evenly) take the 12 nearest in mean floor brightness. The background is their per-pixel median. So the lights coming on do not make the whole floor new.
  2. Gain. gain = mean(background floor) / mean(frame floor), clamped to 0.67 to 1.5; the frame is multiplied by it. An overcast afternoon against a sunny morning. On the spill frame it was 1.08.
  3. Masks. A pixel is a candidate when all of these hold. bright: mean over RGB of gain·frame − background > 30. pale: mean > 120 and max − min < 40 (milk is grey, a crate is not). smooth: the largest luminance step in its 3×3 window < 18 (a liquid has no edges). new: pale in fewer than 30 % of the 12 background frames (a floor marking or a standing puddle is pale in most of them). Outside the detector's person and vehicle boxes grown by 8 % on each side, and in the floor zone.
  4. Blobs. Connected components of the mask dilated by one pixel, so a thin stream is one blob and not a line of specks. A blob counts if it is 0.05 % to 12.5 % of the picture (29 to 7,200 px; bigger is a lighting change) and its ring, the 4-px band around it with at least 8 px in it, is at least 15 grey levels darker (a lit bare floor is pale everywhere and has no ring). Score = Σ min(blob, 288 px) / 57,600: a blob counts at most 0.5 % of the picture, so one sunlit slab does not outrank three puddles.
  5. Sheet. Frames sorted by score, one per camera per clip per 10 minutes, the top 24 on a contact sheet. A run over the frames of 4 November took about five minutes.

What it did on the spill frame is in Figure 12. The candidate mask, 1,017 px after the newness rule, is mostly the tanker's steel body at the lower left. Clip frames carry no detector boxes in the scanner, since the boxes come with the hourly frames' manifest, so nothing masked the tanker, and its 622-px blob with a ring contrast of 53 made the whole score, 0.0074. Inside the label box the stream left 5 px, under the 29-px minimum.

The frame was on five of the sheets, between 10th and 22nd of 24 at 0.007 to 0.013, because of the tanker, and the eye found the stream. The false positives on the sheets, in order of how often, were lamp-lit or sunlit bare floor and walls; white trucks, tankers and cans outside the boxes; white crates; shiny wet tiles; and milky wash water that never dries at one site.

The same spill frame with the scanner masks drawn over it: small patches on the tanker body and the pad, and almost nothing on the stream
candidate mask, dropped (too small, or no ring)blobs kept, 758 px: the scorelabel box
Figure 12. The scanner's masks on the spill frame, recomputed with the frames it had on 4 November, score 0.0074 as on that day's sheet. The kept blobs are the steel top of the small tanker at the lower left and a sliver at the left edge.

The label box in Figure 12 holds 5 candidate pixels and no blob. That is the whole of the miss: the scanner's smallest blob is 29 px, and the stream never reached it.

The fix tried: a spill row on the event

The label is one box drawn by eye, at x 0.44, y 0.80, w 0.13, h 0.20 of the frame. It is the same box on all 142 frames of the event clip, one every 10 s, since the stream did not move, and the same box on the 150 frames of the 09:05 clip of the same camera, which show mud and concrete and no spill.

The features are the class head's 128-channel feature at the cell under the box centre, averaged over a window of cells, as for the brand and fire rows. Level 1, stride 16 on a 40×40 grid, takes a 5×5 window, which covers 160 px of the 1,280-px frame. Level 2, stride 32 on 20×20, takes 3×3, which covers 192 px. The search-model variant instead embeds a crop of the box grown by 30 % on each side.

The negatives are of three kinds. The first is the dry clip's box. The second is the dry frames' floor cells: every cell at level 2 and every second one at level 1, with its centre in the lower two-thirds and none within a window of the box. The third is the other cameras' floor cells, from their hourly frames and every eighth clip frame, split in two by a hash of the file path (SHA-1 under 0.5 goes to the fit), every second frame of each half.

At the time of the run that was about 420 frames in the fit and 412 held out, 99,360 level-2 cells. For the crop variant it was one random floor crop per dry frame and two per other-camera frame, 994 in the fit and 824 held out.

The fit is the same LDA as the brand and fire rows, on the first half of the event, 71 frames, the first half of the dry clip, 75, and the fit half of the other cameras.

d = (C + λ · tr(C)/n · I)−1 (μspill − μother), d ← d / ‖d‖, cut = maxother d · f

The cut-off is the owner's rule: above every negative the fit saw, 116,000 cells at level 2.

Measured

The test is the later 71 event frames, which give recall; the later 75 dry-box frames, which give dry alarms; and the 412 held-out frames of the other cameras, which give unseen alarms, a frame counting as an alarm when any floor cell crosses the cut.

RowRecallDry alarmsUnseen alarms
head level 2, window 3, λ = 10, negatives from the same and other cameras0.9152 of 752 of 412
head level 1, window 5, same negatives, λ = 10.0140 of 753 of 412
search-model embedding of the region crop, λ = 100.9860 of 751 of 412

Three spill rows on the later half of the event, the later dry frames, and 412 unseen frames.

The crop embedding is best, but it has to be handed the region, and the scanner cannot hand it a 2-px stream. No variant separates the test sets cleanly. In each, the lowest-scoring later spill frame sits below the highest-scoring negative, by a margin of −3.4 for the level-2 head row and −0.06 for the crop row.

What it does not fix is the shortage of evidence. It is one event: one camera, one pad, one overcast afternoon, held out by time only. To trust the row would take spills on other pads and at night, dry negatives across days with washing water, sky in puddles and residue, a fit held out by camera, and a scanner that can find a 2-px stream at full resolution. The scanner keeps running; the row waits.

The detector was slow on the CPU, and the two usual fixes cost too much

Every pass costs CPU time on the server, and the browser's live view feels it more. The two usual ways to buy speed without training, a smaller input and INT8 weights, were both tried on the same frames against fp32 at 640. Both were rejected: 512 px lost 8 % of the people and 20 % of the vehicles for a third less time, and INT8 was slower and agreed with the reference on only 60 % of frames.

A smaller input shrinks everything, and the far-off people and the half-hidden trucks that the earlier sections worked to find are the first to go. Dynamic quantisation of the whole file was slower, not faster, on this CPU, and it changed enough boxes near the cut-off to lose the count agreement the rest of the work depends on.

What was changed

resize_input(s) sets the input to s×s and rewrites the attention blocks' baked reshapes: a [1,4,128,400] constant becomes [1,4,128,(s/32)²], and a […,20,20] one becomes s/32. It regenerates the anchor grids /model.23/Constant_12 and Constant_13, which are [1,2,8400] with cell centres at +0.5 on the 80, 40 and 20 grids, and the stride vector Constant_14. The convolutions are size-free and need nothing.

INT8 was dynamic quantisation of the whole file.

Measured

Both variants were run on the same frames with fp32 at 640 as the reference.

VariantSizeCPU msAgainst fp32 at 640
512 pxa third less−8 % people, −20 % vehiclesrejected
INT8 dynamic10 MB (was 38)207 (was 111)60 % count agreementrejected

Two speed variants against the fp32 model at 640 px.

What this does not fix is the browser, where the same file runs through a different runtime; that is the open benchmark below.

Cameras went foggy, banded or black, and nothing reported it

On the night of 4 November eight camera domes at Site 8 were smeared with haze, one channel had broken into coloured bands, another into streaks, and one frame was black. The detector counted on those pictures as if they were fine, and nothing told anyone the pictures were not. Camera health is now checked on every stored frame from a few image statistics, with no model. On the first night, 1,776 frames of 119 cameras, it flagged 23 fogged frames of which 18 were right by eye, 4 banded frames of 4, and 1 black frame of 1. It is adopted and runs in the product.

The detector has no notion of a bad picture. A fogged frame gives it fewer boxes, not an error, and a frame of coloured bands gives it none. The failures that matter here are the ones a person sees in a second, so the check is built from what a person sees: how much contrast there is, how sharp the edges are, whether the picture is striped, lit, or the same as an hour ago.

The statistics

Each frame is decoded at 320×180. The top and bottom 9 % of rows go, since they hold the recorder clock and the camera name, and the 320×148 body is reduced to a few numbers in numpy.

g       = 0.299 R + 0.587 G + 0.114 B;  its mean, std, p5, p95
sharp   = var(4-neighbour Laplacian of g)
edge    = log(1 + mean |Δx g| + |Δy g|) per 8×8 block
          40 × 18 = 720 blocks
flat    = blocks with std(g) < 4
detail  = median over textured blocks (std > 6)
          of std(Laplacian) / std(g)
          ≈ 1.8 on a sharp step, ≈ 0.7 on a 4-px ramp
          the site's median is 1.75
aniso   = mean |Δy g| / mean |Δx g|
          the same on R − G and B − G
halo    = share of glow pixels (120 < g ≤ 200)
          within 4 px of a lit core (g > 200)
white   = share of g > 235
uniform = share within ±6 of median(g)
sat     = mean (max − min) / max over RGB, where max > 30
gray    = g at every second pixel, 160 × 74, for frozen

On this CPU that is 3 ms to decode at draft size and 7 ms of arithmetic per frame, timed over 60 frames. The product runs a Go port of the same code and thresholds in its frame worker, right after each kept frame is stored: one frame an hour per camera plus the counted peaks, one per 15 minutes.

The reference

Several of the conditions compare a frame with the camera's own recent frames. The reference is the 10 usable frames nearest in time, where usable means not black, not one flat colour, and std of 6 or more. It never includes the frame itself or one within 60 s of it, and it needs at least 3 frames, or the reference checks stay silent. Nearest in time means a night frame is judged against night frames and a day frame against day. The reference holds the per-block median of the edge layout, and the median sharpness, detail and black level, p5.

The product also keeps a baseline per camera and slot, day being 07:00 to 17:00 and night the rest: the first week of usable frames, or ten frames the operator points at with a button. A camera moved a week ago agrees with its own recent frames, so moved and blocked are judged against the baseline too.

Nine conditions

The conditions are checked in the order of the table, each with a score in 0 to 1 and an evidence frame. A black frame is judged for nothing else, nor is a corrupt one; a fogged frame is not also blurred; a blocked one is not also moved. The last column is what the first night produced.

ConditionStatisticReferenceThresholdFirst night
blackp95 and mean of g; or uniform (a recorder's no-video card)nonep95 < 45 and mean < 28; or uniform ≥ 0.921 frame, right
corruptaniso; chroma aniso when the chroma gradient ≥ 0.5noneaniso outside 0.35 to 2.8: streaks; chroma aniso outside 0.5 to 2.0: colour bands4 frames on 2 cameras, all right
foggedfog = 0.6·soft + 0.4·haze + 0.15·halo; soft = (1.25 − detail) / 0.55; haze = (p5 − 35) / 40 × (150 − (p95 − p5)) / 60; each term clipped to 0 to 1nonefog ≥ 0.50 on a frame with std ≥ 6 and p5 ≥ 2523 frames on 11 cameras, 18 right
blockedshare of flat blocks; edge energy kept in them and kept elsewhere, against the referencemedian edge layoutflat ≥ 40 %; the reference had ≥ half its mean edge energy there; kept there ≤ 0.35; kept elsewhere ≥ 0.5. Without a reference: flat ≥ 60 % and detail ≥ 1.25none (five earlier flags tuned away)
blurredsharp / median sharp; detail / median detailmedian sharp, detail, p5; layout correlation< 0.35 and < 0.65; layout correlation ≥ 0.3; p5 lifted < 20 (more is fog)none (one tuned away)
overexposedwhitenone≥ 0.20none
movedPearson correlation of the edge layout with the reference; the best over shifts of up to 4 blocksmedian edge layoutcorrelation < 0.3, and the flagged frames must span ≥ 30 min; a shifted correlation ≥ 0.6 and 0.25 better reads as tiltednone (one 2-minute tanker dropped)
frozenmean |gray − gray of the earlier frame|the latest earlier frame ≥ 60 s before< 0.6 grey levelsnone
ir_daysat, 07:00 to 17:00 device timenonesat < 0.045 and mean > 35none

The nine health conditions: statistic, reference, threshold, and what the first night flagged.

How the thresholds were set

The thresholds were chosen by eye on the site's frames. Run, look at the contact sheet of flagged frames and the sample of unflagged ones, write a verdict per flagged frame into labels/health.json, move the number, run again. The verdict file has 36 entries, including the flags the rules now drop.

Three of those shaped the rules. A blurred flag at a camera whose floor had gone from crates to bare concrete: the Laplacian variance fell but the detail ratio did not, hence the detail gate. A moved flag at Site 4 ch3, where a tanker stood across the lens on two frames two minutes apart, hence the 30-minute span. And five blocked flags on smeared domes, a truck's canvas roof at 23 % flat, and a dark room whose reference was dark there too, hence the 40 % rule, the sharp-rest rule and the test of the reference's edge energy in the region.

The first night

The first night was 1,776 frames of 119 cameras: 720 hourly frames from 23:00 on 4 November to 01:10 on 5 November, and 1,056 daytime clip frames thinned to one per 5 s. It flagged fogged on 23 frames of 11 cameras, corrupt on 4 frames of 2 cameras, and black on 1. Daytime clip frames flagged nothing.

By eye, 18 of the 23 fog flags were right: eight channels at Site 8, with smeared domes, haze blotches and a milky haze over the whole picture at ch9, which scored 1.00 with blacks lifted to 99 to 106 and a range of 60 to 78, and a haze over the dock at Site 5 ch1.

The five wrong were three frames of Site 8 ch2, one of ch8 and one of ch1, each a soft, low-resolution picture of a lit room. Such a picture has no deep blacks, with p5 at 78 to 82, and no sharp step, with detail at 0.85 to 0.95, so both the haze term and the soft term read it as fog, at 0.69 to 0.78.

Corrupt was 4 of 4: colour bands on all three frames of Site 8 ch6, with chroma anisotropy 0.29 to 0.32, and horizontal streaks on ch13, anisotropy 5.8, which was also the black frame, with p95 31 and mean 20.

The misses were found on the unflagged sample. Site 8 ch4's crate-washer haze scored 0.50, just under the cut, and ch7's refrigeration haze 0.48. At Site 15 a blotchy night fog with sharp edges scored 0.26, with a detail ratio of 1.07. Grainy infrared fog reads as detail, so the detail term cannot see it, and the halo term only helps where there are lights in view. That is what the check does not fix.

A milky, washed-out camera picture of stacked crates
Figure 13. Fogged, Site 8 ch9, 23:41. Fog score 1.00.
A camera picture broken into coloured horizontal streaks
Figure 14. Corrupt, Site 8 ch6, 00:57. Chroma anisotropy 0.29.
0.40.50.60.70.80.91.0cut 0.50fog scoreSite 8 ch9Site 8 ch9 23:04: fog 0.98, fogged by eyeSite 8 ch9 23:41: fog 1.00, fogged by eyeSite 8 ch9 00:42: fog 1.00, fogged by eyeSite 8 ch3Site 8 ch3 23:05: fog 0.83, fogged by eyeSite 8 ch3 23:41: fog 0.71, fogged by eyeSite 8 ch3 00:46: fog 0.62, fogged by eyeSite 8 ch2Site 8 ch2 23:03: fog 0.70, not fogged by eyeSite 8 ch2 23:41: fog 0.78, not fogged by eyeSite 8 ch2 01:05: fog 0.69, not fogged by eyeSite 8 ch16Site 8 ch16 23:40: fog 0.72, fogged by eyeSite 8 ch16 00:42: fog 0.54, fogged by eyeSite 8 ch5Site 8 ch5 23:02: fog 0.62, fogged by eyeSite 8 ch5 23:43: fog 0.62, fogged by eyeSite 8 ch5 00:47: fog 0.69, fogged by eyeSite 8 ch10Site 8 ch10 23:05: fog 0.60, fogged by eyeSite 8 ch10 23:41: fog 0.60, fogged by eyeSite 8 ch10 00:56: fog 0.68, fogged by eyeSite 8 ch1Site 8 ch1 23:05: fog 0.50, not fogged by eyeSite 8 ch1 01:05: fog 0.62, fogged by eyeSite 8 ch11Site 8 ch11 23:04: fog 0.58, fogged by eyeSite 8 ch14Site 8 ch14 01:09: fog 0.58, fogged by eyeSite 8 ch8Site 8 ch8 23:40: fog 0.58, not fogged by eyeSite 5 ch1Site 5 ch1 00:44: fog 0.61, fogged by eyeSite 8 ch4Site 8 ch4: fog 0.50, under the cut, fogged by eyeSite 8 ch7Site 8 ch7: fog 0.48, under the cut, fogged by eye
flagged, fogged by eyeflagged, not fogged by eyeunder the cut, fogged by eye
Figure 15. Fog score of every flagged frame on the first night, one row per camera, from runs/health/report.json and the by-eye verdicts in labels/health.json. The two crosses are the misses that had a score written down.

Adopted. In the product a condition opens an alarm only after 3 consecutive checks, which with hourly frames and the counted peaks is 30 to 90 minutes, and closes it on the first clear check. There is one alarm per camera per condition, with the evidence thumbnail, and none from frames older than a day.

The browser detector ran on one thread

The console also runs the model in the viewer's browser, for live boxes on a stream. It uses ONNX Runtime Web, on the GPU through WebGPU where the browser offers it and on WebAssembly otherwise. On a laptop without a usable GPU a frame took about 0.9 seconds, and the page froze while it ran. We measured what each candidate change buys, on the same 20 frames, in a real Chromium.

The first finding was that the runtime was silently running on one thread. Multi-threaded WebAssembly needs two security headers from the server, cross-origin isolation, and without them the runtime drops to one thread even when asked for four. The console had never sent them.

Here is a short lead-in to the measurements. The reference is the same model on the server's CPU. Agreement means the fraction of frames where the browser's people and vehicle counts match the reference.

Variantms per frameAgreementNote
WebAssembly, one thread, as shipped860 to 8900.85the baseline a CPU client gets
WebAssembly, two threads, isolated730 to 8200.8510 to 18 % faster, shipped
Four threads requested, no headers8780.85silently one thread
fp16 weights on WebAssembly1,080 to 1,4900.80slower, and one count changes
Raw head, boxes ranked in JavaScript9490.85no gain; the in-file tail is cheap
Inference in a worker7920.85same speed; the page stops freezing
.ort file instead of .onnxsame1.00loads 200 ms faster, once
Preprocessing variants3 of 850nothing to win

Chromium, 20 frames, median after warm-up, on a 4-core machine with no GPU.

The 0.85 is the same three frames for every browser variant: boxes a few hundredths from the cut-off whose score moves with how the picture is resized, since the browser's canvas and the server's image library resample differently. That gap exists in production today and none of these changes touch it.

What shipped

The two isolation headers, two threads when the browser is isolated with a cap of one below the core count, and the runtime's files served from the console itself instead of a content delivery network. Together that is the 10 to 18 %. The console also got a developer page that runs this same benchmark in any browser, which matters because of the next paragraph.

What this machine could not measure

The GPU path. The machine these numbers come from has no GPU, so WebGPU ran on a software renderer at a minute per frame, and the half-precision shaders refused to compile. What could be checked is placement: with the file as shipped, 320 of its operations run on the GPU and 9 small index operations on the CPU, and with the raw-head export all 304 run on the GPU, with counts matching the reference either way. So the file is fine for WebGPU. How fast it is, and whether fp16 holds its counts there, needs a laptop or phone with a real GPU, and that is what the developer page is for. The table gains its GPU rows when one has been run.

Every experiment, in the order it was run

Everything above, and a few things that had no section of their own, is in one table: what was tried, what it was measured on, what the numbers said, and what was decided. Adopted means it is in the product or the server today; parked means it works on what it was shown and has not seen enough to ship; rejected means the numbers said no. The table grows as experiments run.

WhatMeasured onResultDecision
Baseline, original model as the product runs it230 stored frames, 117 cameras82 % count agreement; 136 of 538 boxes under 0.45; 74 ms median CPUreference
Vehicle merge, noisy-OR of rows 1, 2, 3, 5, 7 into row 7230 frames; 346 daylight yard frames+20 boxes (18 real), 0 lost; +52 boxes, 17 distinct, 16 realadopted, deployed
Person dedup thresholdOverlapping person pairs on a quiet and a busy clip46 of 55 pairs at IoU ≥ 0.9 are one person; 0.5 to 0.85 are neighbours0.9 adopted (vehicle 0.7)
Decision layer: hysteresis 0.35/0.20, 2 hits, 1.5 s holdTwo 10-min clips at 2 fpschanges/min 15.9 → 6.9 and 46.2 → 30.0; blips 55 → 6 and 132 → 56adopted, server
Nested rule (part ≥ 0.8 inside; group by score or member area 0.15)Yard clips118 wrong frames fixed, about 52 remainadopted
Yard cut-off 0.12 per camera436 daylight frames, 104 cameras; 404-frame rerun on 14band precision 0.61 overall, 0.75 to 0.92 on yards; rerun 0.85adopted on 12 cameras
Ignore zones round fixed offenders14 candidate camerasfalse distinct 11 → 3; precision 0.83 → 0.90adopted
Two-look rule for gained boxes699 clip frames, 6 camerasfalse boxes 319 → 239, real 1,398 → 1,160; static offenders surviverejected
Tiling, full frame + 2×2, people only230 frames≈70 more real people; 5 passesadopted, server
Input 512 pxSame frames, fp32 at 640 as referencea third faster; −8 % people, −20 % vehiclesrejected
INT8 dynamic quantisationSame10 MB; 207 ms vs 111 ms; 60 % agreementrejected
Brand row in the detector's head features319 crops, 16 sites, held out by site0.805 at stride 16, 0.826 at stride 32rejected, target ≥ 0.9
Brand prototype in the search model's spaceSame crops; live check after deployment0.875 quantised (0.906 fp32); about 26 of the top 29 rightadopted, deployed
Fire row, closed form, no base classTwo public picture sets held out; 367 unseen site frames0.515 / 0.279 of images at 1 alarm in 367; hard negatives no help; level 2 only at zero alarms 0.272parked
Spill row on the one eventSecond half of the event; 412 unseen framesrecall 0.915, 2 alarms; crop embedding 0.986, 1 alarmparked, one event
Camera health from image statisticsNight frames of 4 and 5 November, judged by eyefog 18 of 23, bands 4 of 4, black 1 of 1adopted, deployed
Cutout search, two vectors per box720 frames, 1,673 boxes202 ms per cutout; "a milk tanker" top 12: 7 tankers, 2 crate trucks, 3 milk vansadopted, deployed
Dedup and nested rule as graph nodes after the top-30012,770 frames against the Python pipeline0 frames differ; +1.5 ms per framebuilt, not yet deployed
Text-prompt verification of gained boxes in the search model's space182 judged boxes, then the 363-box rerunAUROC 0.86 then 0.78; on the 14 yard cameras 2 to 5 of 11 false removed for 1 to 3 real lost, zones 8 for 0; 40 ms per croprejected as a gate; kept for ranking clusters offline
Steering, first attempt: the vehicle logit along a fitted direction (damp-lda, damp-contrib; K4, K8; f 0.5, 0.0)999 frames, the judged gained objects of the rerunat best 4 of 48 false removed for 7 of 323 real lost; 24 to 36 removed for 71 to 158 lostrejected, zones kept
Browser detector: isolation headers and two WASM threads, fp16, raw head with a JS tail, worker, .ort, preprocessing20 frames in Chromium, no GPU, against the CPU referencetwo threads 10 to 18 % faster at the same counts; fp16 slower and 0.80 agreement; raw head no gain; .ort 200 ms faster start; WebGPU not measurableheaders, two threads and self-hosted runtime adopted, deployed; GPU rows pending a real GPU
Steering, gated: a pooled pattern at one head layer per grid lowers the vehicle score above a threshold404 judged yard frames, held out by site; three nights, 1,972 frames; 330 daytime frames outside the yards11 of 48 false removed, 0 of 323 real lost; night real trucks lost 0, 4 and 1 of 241, 685 and 724 boxes; daytime 1 of 284; people unchanged on 2,302 frames; +5 % timeadopted, deployed
Steering, one gate per kind of false object (nine kinds)Same yard frames, held out by site13 to 17 of 48 removed for 0 lost in sample; held out 11 to 15 removed for 5 to 6 real lostrejected
Steering, a gated lift for faint trucksSame yard frames27 of 323 real over the cut-off; about 70 extra boxes on parts of counted trucks; 9 whole trucks dropped by the nested rulerejected
Drop boxes that match the camera's multi-day background458 judged yard objects, 31 cameras; 330 daytime frames outside the yardsat 99.5 % of real boxes kept, 2 more false removed for 3 parked trucks lost; outside the yards 2 to 4 % of vehicle boxes dropped, two thirds of them realrejected
Hand-built texture filters in the graph: repetition, flatness, wheels, colour458 judged yard objects, held out by sitealone 0 of 7 crate stacks; with the head feature 3 to 5 more of 95 false, none crates; +20 % timerejected
Random layer of 2,048 units with closed-form output weightsYard objects and brand crops, held out by siteseparation 0.696 to 0.718 against 0.735 linear on the yard; 0.760 against 0.751 on the brandrejected
Vehicles kept from the people tiling passes, full-frame boxes always kept404 judged yard frames; 230 night frames226 distinct real against 129, 16 false against 5; 13 of 1,290 product boxes lost; no extra passesadopted, server
Night floor of 0.50 on vehicles only a tile found, 18:00 to 06:00 device clock138 judged night boxesadded boxes 16 real and 18 false become 10 real and 3 falseadopted, server
Second pass on the top-centre quarter, for cameras that do not tile404 judged yard frames197 distinct real, 8 false, 4 product boxes lost; 1.9× timemeasured, not adopted
Brand, wider definition and prototype fused with text descriptions358 crops, 16 sites, held out by site0.893 of branded found for 25 false of 208, against 0.753 and 19adopted, going to the server
Brand in the detector with colour filters addedSame crops, held out by siteseparation 0.82 head alone, 0.85 with colour, 0.88 in daylight; no colour at nightrejected
Brand at night: greyscale pattern and infrared brightness profileThe night crops of the same setseparation 0.75 head alone to 0.80rejected
Open-vocabulary detector with text classes458 judged yard objects; 358 brand cropskept 220 of 363 real trucks at 0.12; brand separation 0.69rejected

What is still open

The yard numbers are one daylight day. The rerun added frames, not days.

The brand prototype misses at night, and its held-out number comes from 16 sites with a few dozen crops each. The fire row's held-out sets are public pictures, and at zero site alarms it sees a quarter of them. The spill row has seen one spill.

None of it needs training, and all of it waits on more frames.

Every number above was produced by a script against the site's own frames, with the before and after of each change run on the same frames. The pictures are the stored frames with faces, on-screen captions and timestamps pixelated; the boxes are overlays recomputed on them, and nothing is burned into an image.