Research use only. Not a medical device. The outputs are scores against the labels of one dataset. They are not a diagnosis and must not be used for patient care.
Image-level fracture classifier for musculoskeletal X-rays (hand, leg, hip, shoulder), fine-tuned from
convnext_tiny.fb_in22k_ft_in1k on FracAtlas, plus a YOLO11s fracture-box detector trained on the same split. Both are exported to
ONNX. Code, split, paper and the full comparison: fracatlas-fracture-benchmark. Try it in the browser:
fracture-xray-check.
| File | What it is |
|---|---|
convnext_tiny_fracatlas.onnx |
classifier, input image [N, 3, 384, 384], output logit [N, 1] |
convnext_tiny_fracatlas.pt |
the same weights for PyTorch/timm (state_dict, meta) |
yolo11s_fracatlas.onnx |
detector, input [1, 3, 640, 640], output [1, 5, N] = cx, cy, w, h, score (apply NMS yourself) |
config.json |
preprocessing, temperature, threshold and test results |
Convert to grayscale; resize so the longer side is 384 px (aspect ratio kept) and pad to 384 x 384 with black, centred; scale to [0, 1]; repeat to three channels; normalise with ImageNet mean [0.485, 0.456, 0.406] and std [0.229, 0.224, 0.225]. Probability = sigmoid(logit / T) with T = 1.751. Decision threshold (Youden, on validation) = 0.370. If max(p, 1 - p) < 0.8, refer the image instead of answering.
import json, numpy as np, onnxruntime as ort
from PIL import Image
from huggingface_hub import hf_hub_download
repo = "MHkhan50/fracatlas-convnext-tiny"
cfg = json.load(open(hf_hub_download(repo, "config.json")))["classifier"]
sess = ort.InferenceSession(hf_hub_download(repo, cfg["file"]))
img = Image.open("xray.jpg").convert("L") # your X-ray
S = cfg["size"]; s = S / max(img.size)
w, h = max(1, round(img.width * s)), max(1, round(img.height * s))
canvas = Image.new("L", (S, S)) # black square, image centred
canvas.paste(img.resize((w, h), Image.BILINEAR), ((S - w) // 2, (S - h) // 2))
g = np.asarray(canvas, np.float32) / 255
x = np.stack([(g - m) / sd for m, sd in zip(cfg["mean"], cfg["std"])])[None].astype(np.float32)
p = float(1 / (1 + np.exp(-sess.run(None, {"image": x})[0][0, 0] / cfg["temperature"])))
if max(p, 1 - p) < cfg["refer_below_confidence"]:
print(f"p = {p:.3f}: unsure, refer to a clinician")
else:
print(f"p = {p:.3f}:", "fracture likely" if p >= cfg["threshold"] else "no fracture found")
In PyTorch: timm.create_model("convnext_tiny.fb_in22k_ft_in1k", pretrained=False, num_classes=1), then
load_state_dict(torch.load("convnext_tiny_fracatlas.pt")["state_dict"]), with the same preprocessing.
Seed 1 of three, chosen by validation AUROC (0.941); the test set was not used for any choice. The ONNX export matches PyTorch to 3.0e-06 (largest absolute difference on random inputs).
This released seed: AUROC 0.917; sensitivity 0.75 and specificity 0.93 at the threshold; sensitivity 0.77 at 90% specificity; ECE after temperature scaling 0.050; 14% of images referred at confidence < 0.8. Detector box mAP at IoU 0.5 on the test images: 0.321.
Seed ensembles (three seeds, logits averaged), test AUROC with 95% bootstrap intervals:
| Model | AUROC [95% CI] |
|---|---|
| Small CNN | 0.809 [0.763, 0.852] |
| ConvNeXt-Tiny | 0.928 [0.891, 0.957] |
| DINOv2-S frozen probe | 0.873 [0.833, 0.909] |
| DINOv2-S fine-tuned | 0.902 [0.865, 0.934] |
Trained on FracAtlas (Abedeen et al., 2023, Scientific Data 10:521, doi:10.1038/s41597-023-02432-4), CC BY 4.0. Weights: MIT. Author: Muzammal Hussain (ORCID 0009-0001-2570-5686).
convnext_tiny_fracatlas.onnx 111 MBconvnext_tiny_fracatlas.pt 111 MByolo11s_fracatlas.onnx 38 MB