Views
No views yet
HRM family trait, pretrained on Objects365 and fine-tuned on COCO (80 classes). It exports to a clean, TensorRT-compatible ONNX graph (no GridSample, explicit deformable sampling) and runs anywhere from a laptop CPU to a Blackwell GPU.Object detection · live results — running here through TensorRT on an RTX 5060 Ti (Blackwell, sm_120), ~26 ms end-to-end.

![]() | ![]() | ![]() |
![]() | ![]() | boxes + scores are the model's raw output at conf > 0.4 |
| File | What it is |
|---|---|
model.pt | PyTorch checkpoint ({"model": state_dict}), trained with the HRM trait |
model.onnx | TensorRT-compatible ONNX (opset 16, explicit deform, gridsample_nodes: 0) |
meta.json | Full I/O + preprocessing spec and the 80 COCO class names |
src/ | Vendored model code (modified D-FINE-seg + the HRM trait) — needed to load model.pt |
preview/ | Example detections shown above |
meta.json:images: float32[N, 3, 640, 640], RGB, stretch-resized to 640×640, divided by 255 (mean 0 / std 1), channel layout NCHW.logits: float32[N, 300, 80] — apply sigmoid for per-class scores (the model is NMS-free; just threshold).boxes: float32[N, 300, 4] — cxcywh, normalized to [0, 1]. Convert to pixels with the original image size.huggingface-cli login, or pass token= / set HF_TOKEN.model.pt)src/ in this repo.1import os, sys, json
2import numpy as np, torch
3from PIL import Image
4from huggingface_hub import snapshot_download
5
6repo = snapshot_download("Quazim0t0/Byrne-DFINE-N") # pulls model.pt, meta.json, src/
7sys.path.insert(0, repo)
8os.environ["DFINE_USE_HRM"] = "1" # the checkpoint was trained with it
9from src.d_fine.dfine import build_model
10
11meta = json.load(open(f"{repo}/meta.json"))
12names = meta["class_names"]; S = meta["input_h"] # 640
13
14model = build_model("n", len(names), False, "cpu", img_size=[S, S]).eval()
15model.load_state_dict(torch.load(f"{repo}/model.pt", map_location="cpu", weights_only=False)["model"])
16model.cuda() # or leave on CPU
17
18img = Image.open("your.jpg").convert("RGB"); W, H = img.size
19x = np.asarray(img.resize((S, S)), np.float32) / 255.0
20t = torch.from_numpy(x).permute(2, 0, 1).unsqueeze(0).cuda()
21
22with torch.no_grad():
23 out = model(t)
24logits, boxes = out["pred_logits"][0], out["pred_boxes"][0]
25scores = logits.sigmoid(); conf, cls = scores.max(-1)
26for s, c, (cx, cy, bw, bh) in zip(conf.tolist(), cls.tolist(), boxes.tolist()):
27 if s < 0.5: continue
28 x1, y1 = (cx - bw/2) * W, (cy - bh/2) * H
29 x2, y2 = (cx + bw/2) * W, (cy + bh/2) * H
30 print(f"{names[c]} {s:.2f} [{x1:.0f},{y1:.0f},{x2:.0f},{y2:.0f}]")model.onnx, self-contained, no model code)1import json, numpy as np, onnxruntime as ort
2from PIL import Image
3from huggingface_hub import hf_hub_download
4
5onnx = hf_hub_download("Quazim0t0/Byrne-DFINE-N", "model.onnx")
6meta = json.load(open(hf_hub_download("Quazim0t0/Byrne-DFINE-N", "meta.json")))
7names = meta["class_names"]; S = meta["input_h"]
8
9sess = ort.InferenceSession(onnx, providers=["CPUExecutionProvider"]) # or CUDAExecutionProvider
10img = Image.open("your.jpg").convert("RGB"); W, H = img.size
11x = np.asarray(img.resize((S, S)), np.float32) / 255.0
12x = np.transpose(x, (2, 0, 1))[None] # NCHW
13logits, boxes = sess.run(["logits", "boxes"], {"images": x})
14scores = 1 / (1 + np.exp(-logits[0])) # sigmoid
15cls = scores.argmax(1); conf = scores.max(1)
16for i in np.where(conf > 0.5)[0]:
17 cx, cy, bw, bh = boxes[0, i]
18 print(names[cls[i]], round(float(conf[i]), 2),
19 [round((cx-bw/2)*W), round((cy-bh/2)*H), round((cx+bw/2)*W), round((cy+bh/2)*H)])model.onnx → engine)GridSample). Build fp32 — the D-FINE decoder is numerically sensitive and must stay FP32.trtexec:1trtexec --onnx=model.onnx --saveEngine=byrne_dfine_n.engine \
2 --minShapes=images:1x3x640x640 --optShapes=images:1x3x640x640 --maxShapes=images:8x3x640x640nvcr.io/nvidia/tensorrt:25.08-py3 with --build-arg CUDA_ARCH=120:1# inside the dfine-cpp container
2./dfine_build model.onnx byrne_dfine_n.engine # ONNX -> fp32 engine (~85 s, ~23 MiB)
3./dfine_detect byrne_dfine_n.engine your.jpg # ~26 ms/framelogits, cxcywh-normalized boxes, no NMS).DFINE_USE_HRM=1) so the trained gate is preserved, and load model.pt with --init.detection-datasets/coco and toilaluan/object365 straight from the Hub and builds D-FINE targets on the fly (boxes normalized, category ids remapped to 0–79):1DFINE_USE_HRM=1 python train_family_dfine.py \
2 --init model.pt \
3 --dataset coco \
4 --model n --steps 30000 --batch-size 8 --lr 1e-4 \
5 --num-workers 2 --save-every 5000 \
6 --out runs/byrne_dfine_n_finetune--init is shape-filtered — matching tensors load, the 80-class heads reinitialize if your class count differs (Objects365→COCO reinitialized 9/686 tensors this way).--pretrained-backbone to start the HGNetV2 backbone from ImageNet (much faster convergence) when training a fresh stage; omit it to keep the current weights.eval_det_loss.py), not the augmented training loss.dfine-cpp/trt-files/scripts/export_dfine_onnx.py --deform explicit --dfine-src <this src/>. The custom RMSNorm in the HRM trait is decomposed from primitives specifically so the graph exports to ONNX opset 16 (fused aten::rms_norm has no symbolic).src/ is a drop-in modified D-FINE-seg — use its standard training loop with DFINE_USE_HRM=1.