SafeSynth RT-DETRv2-R18 Hard-Hat Detector
This is the best validation-selected checkpoint from SafeSynth's controlled
four-arm RT-DETRv2-R18 experiment. The selected arm is deliberately
real_only: it used all 3,500 frozen real Train images and zero synthetic
images. The negative selection result is part of the release, not something
hidden by publishing a synthetic arm.
Model details
| Item | Value |
|---|
| Architecture | RT-DETRv2 with ResNet-18 backbone |
| Classes | helmet, head, person |
| Training composition | 3,500 real Train, 0 synthetic |
| Validation set | 756 real images |
| Seed | 1337 |
| Optimizer steps | 10,900 |
| Selected checkpoint | step 1,752 (best frozen-validation checkpoint) |
| Input preprocessing | Resize to 640x640, rescale by 1/255, no ImageNet normalization |
| Weight format | Safetensors |
The model predicts a helmet box around the helmeted head, a head box for a
bare head, and the inherited person class. The third class is unreliable
because the source dataset's person annotations are substantially incomplete.
Four-arm result
All arms used the same real Train set, frozen real Validation/Test sets, seed,
and 10,900-step optimizer budget. Synthetic arms used 3,500 generated images;
their real-image exposure was about half that of the real-only arms.
| Arm | Primary AP_small | Primary mAP | Bare-head recall | Real-image exposures |
|---|
| real_only | 0.4511 | 0.5341 | 0.9875 | 49.83 |
| standard_aug | 0.4236 | 0.4958 | 0.9875 | 49.83 |
| unfiltered_syn | 0.3759 | 0.4597 | 0.9898 | 24.91 |
| filtered_syn | 0.3664 | 0.4858 | 0.9886 | 24.91 |
The 1,000-resample, image-level bootstrap intervals for primary AP_small were:
| Arm | AP_small (95% CI) |
|---|
| real_only | 0.4511 [0.4307, 0.4753] |
| standard_aug | 0.4236 [0.3993, 0.4530] |
| unfiltered_syn | 0.3759 [0.3474, 0.4064] |
| filtered_syn | 0.3664 [0.3426, 0.3956] |
AP_small is the mean of helmet and bare-head AP for COCO-small objects,
computed in each image's native original annotation coordinates (415/416
pixel edges), not after resizing to 640x640. person is excluded from the
primary mAP because its source annotations are known to be poor.
Usage
1import torch
2from PIL import Image
3from transformers import RTDetrImageProcessor, RTDetrV2ForObjectDetection
4
5repo_id = "steven0226/safesynth-rtdetrv2-r18"
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8processor = RTDetrImageProcessor.from_pretrained(repo_id)
9model = RTDetrV2ForObjectDetection.from_pretrained(repo_id).to(device).eval()
10image = Image.open("construction_site.jpg").convert("RGB")
11inputs = processor(images=image, return_tensors="pt").to(device)
12
13with torch.inference_mode():
14 outputs = model(**inputs)
15
16target_sizes = torch.tensor([(image.height, image.width)], device=device)
17result = processor.post_process_object_detection(
18 outputs,
19 target_sizes=target_sizes,
20 threshold=0.07,
21)[0]
22
23for score, label_id, box in zip(
24 result["scores"], result["labels"], result["boxes"], strict=True
25):
26 label = model.config.id2label[int(label_id)]
27 print(label, float(score), [round(x, 1) for x in box.tolist()])
The 0.07 threshold was selected on the frozen Validation set for the repository's
deployment analysis. Recalibrate it for a new camera, site, class balance, and
false-alarm cost. Never tune it on the Test set.
Intended use
This checkpoint is intended for reproducible research, teaching, controlled
comparison, and prototyping of hard-hat/bare-head detection. It is not a
certified safety product. A human safety process must remain authoritative.
Limitations and responsible use
- Do not treat the reported AP as an absolute quality guarantee. SHEL5K
re-annotated the same 5,000 source images with 75,570 labels versus 25,502 in
the original; all repository claims are relative comparisons on one frozen
Test set.
person AP is not a reliable measure because the upstream person labels are
sparse and inconsistent.
- Training and bootstrap evaluation used one seed. This checkpoint is the
validation-selected model for that protocol, not evidence of universal
superiority.
- The pre-registered synthetic-artifact gate failed (AUC 0.9053 versus a maximum
of 0.60). Synthetic augmentation did not robustly improve RT-DETRv2 and showed
architecture-sensitive, inconclusive behavior in an RF-DETR cross-check.
- Data are drawn from a public construction-worker dataset and may not represent
every geography, PPE design, skin tone, workplace, lighting condition, camera,
or occlusion pattern.
- Do not use the model as the sole basis for discipline, access denial,
surveillance, or any decision that can harm a worker.
License
The weights are a fine-tune of PekingU/rtdetr_v2_r18vd, whose Hugging Face
repository declares Apache-2.0. These derived weights are released under
Apache-2.0. SafeSynth source code is MIT; the immediate training dataset is
CC0 1.0. See the linked repositories for the full provenance and notices.