INFRA INTELLIGENCE JP Contact

How can you count junction traffic with AI? A model that automates traffic survey counts from camera recordings

Model Lab has released a model that sorts vehicles into nine types and counts which road each one entered from and left by, using video from a fixed junction camera. The weights are under Apache-2.0.

The Shibuya scramble crossing seen from above, with a red bus, a taxi and a white van crossing

Model Lab has released a model that counts vehicles by type and by direction from the video of a fixed camera at a junction. It was built so that the job of going back through hours of recordings and counting every vehicle by hand could be handed to AI. On a three-minute recording of the Shibuya scramble crossing, it correctly counted 93 of the 103 vehicles that entered the junction and 98 of the 104 that left it. The weights are published under Apache-2.0, so they can be built into business systems.

Part of a junction seen from above. A white car, a red bus, a white van and a light-blue car each have a box labelled with their vehicle type, with lines tracing their paths and the letter of the road they are heading for
Video: SHIBUYA COMMUNITY NEWS (sibch.tv) / Internet Archive (CC BY 3.0)

What can it count?

Japan's road traffic census groups traffic into four vehicle types (cars, buses, light goods vehicles and heavy goods vehicles) or two classes (small and large vehicles) (source: MLIT). Junction surveys also need turning movement counts: which road each vehicle came from and which road it left by. Going back through hours of recordings to sort every vehicle by type and destination takes real patience.

This model detects vehicles in nine types: car, van, kei truck, small truck, medium/large truck, trailer, bus, motorcycle and special vehicle (construction machinery, work vehicles and so on). A table that maps the nine types onto the census's four types and two classes comes with the release, so the counts can be totalled the same way as the census. Bicycles and pedestrians are not detected.

Part of the junction video. A kei truck and two cars have boxes, with lines tracing their paths and the letters C, A and D for the roads they are heading for
Video: SHIBUYA COMMUNITY NEWS (sibch.tv) / Internet Archive (CC BY 3.0)

How does it count?

First, it detects vehicles in each frame and links each one to the same vehicle in the previous frame with tracking (ByteTrack). Then a line (a gate) is drawn across the mouth of each road that joins the junction.

Diagram of a four-way junction. Gate lines cross the mouths of roads A to D, and a line shows a vehicle entering from A and leaving by D

Whether a vehicle has crossed a gate is judged by the midpoint of the bottom edge of its box. If the tracker loses a vehicle and gives it a new number, it is still counted as the same vehicle when it vanished and reappeared close in place and time. The counting code is published alongside the weights.

The model is based on RF-DETR Small. Public weights pre-trained on COCO were further trained on images of Japanese roads.

How accurately does it count?

Counts were checked on a recording from a live camera at the Shibuya scramble crossing (daytime, three minutes). The reference counts were not made by a person: a separate AI counted them from the frames without seeing this model's results.

Bar chart. Of the vehicles entering the junction, 93 of 103 were counted correctly; of those leaving, 98 of 104; by direction, 72 of 91

Direction scores lower because it only matches if the same vehicle is followed all the way from entry to exit.

Detection was measured on 429 test images (1,369 vehicles) from eight areas not used for training.

Bar chart. Precision 0.84, recall 0.75, recall regardless of vehicle type 0.82. Recall by type: car 0.82, bus 0.81, medium/large truck 0.58, motorcycle 0.56, van 0.51

Cars and buses have recall above 0.8, but vans stop at 0.51 and are sometimes mistaken for cars. Kei trucks, small trucks, trailers and special vehicles had fewer than 30 examples in the test images, so no per-type figures are given for them. The reference boxes on the test images were also drawn by AI, and only the rarer types were checked by a person.

Where does it struggle?

At a busy junction, when vehicles pass each other or one is hidden behind a large vehicle, a vehicle can be lost or its track number can jump to another vehicle. When that happens, the direction counts drift.

Part of the junction video. The white bus in front has a box, but the red bus half hidden behind it has none
Video: SHIBUYA COMMUNITY NEWS (sibch.tv) / Internet Archive (CC BY 3.0)

Vehicles that appear small (under 32 pixels square) and motorcycles in video shot from high up are also easily missed. Once, at night, it missed an advertising truck with a lit-up body. If you use the counts for traffic surveys or safety decisions, check them against the video first rather than using them as they are.

What licence and formats?

The weights and code are published under Apache-2.0. They can be built into business systems and products, and modified and redistributed. Formats are PyTorch and ONNX.


Inputs, outputs and full evaluation results: Vehicle RF-DETR Small

Weights: Hugging Face

Apps built around this model can also be made to order: AI App Development

Cover photo and video: SHIBUYA COMMUNITY NEWS (sibch.tv) / Internet Archive (CC BY 3.0)

Last checked: 12 November 2026

References (in Japanese)

Contact