Floor Plan Door Detection - RF-DETR

A fine-tuned RF-DETR Small model for door openings in architectural floor plans.

Fine-tuned using public floor-plan datasets and additional architectural drawing crops.

One opening counts as one item; double doors should count as one opening. The single foreground class is door (ID 0). Windows and cabinets are outside the intended class. Predictions require human review, including areas where no box was proposed. Counts are preliminary and do not automatically identify unique physical openings across repeated drawings.

License scope: model.safetensors model weights are Apache-2.0. The supplied Python runner, including PDF functionality, is AGPL-3.0-only. See LICENSING.md and NOTICE.

Install

Tested with Python 3.13.3 on macOS ARM64. Download the repository files into one directory, then run there:

python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python -m pip check

requirements-lock-macos-py313.txt provides the complete tested dependency resolution for that platform. Training and web-server extras are not required. The weights are stored in safetensors and loaded directly by model_loader.py with the pinned rfdetr==1.11.2 implementation. No .pth file, pickle loading, conversion back to pickle, or base-weight download is required at runtime. This package does not implement or claim Transformers pipeline() / from_pretrained() compatibility.

Predict

Image:

python predict.py --input plan.png --output results-image --device cpu

PDF (explicit 1-based PDF page selection required):

python predict.py --input plan.pdf --pages 1 --output results-pdf --device cpu
python predict.py --input plan.pdf --pages 2,4-6 --output results-selected --device cpu

Each output directory must be new. model.safetensors is selected relative to the script by default. Apple Silicon users can use --device mps. --device cuda requires a compatible PyTorch/CUDA installation; CUDA and other operating systems have not been validated for this release.

Optional drawing-area crop and render preview:

python predict.py --input plan.pdf --pages 1 --output results-roi --device cpu --roi 5 10 82 90
python predict.py --input plan.pdf --pages 1 --output preview --preview-only
python predict.py --help

ROI bounds are left/top/right/bottom percentages. Image loading applies EXIF orientation, composites transparency onto white, and converts to RGB. PDFs are rendered in RGB at 150 DPI by default, with a 40-million-pixel page limit.

Inference uses 768ร—768 white-padded tiles with 384-pixel stride, model resolution 512ร—512, confidence threshold 0.3, tile-boundary rechecks, and final greedy NMS with IoU 0.5. The direct loader constructs RFDETRSmall(pretrain_weights=None, num_classes=1, resolution=512, device=...), strictly loads the included safetensors state, restores class names, and uses the existing RF-DETR prediction facade. The existing box/score handling is preserved without adding a class filter. Override settings with --dpi, --threshold, --nms-iou, --checkpoint (a safetensors file), or --model-config (defaults beside weights); changing settings can change predictions.

Direct loader

model_loader.py reads model_config.json and model.safetensors directly. The minimal config contains only the pinned RF-DETR version, Small variant, resolution, foreground class count and class mapping. Architecture defaults are fixed by rfdetr==1.11.2: a windowed DINOv2 Small encoder, three decoder layers, patch size 16, positional grid 32 and 300 queries / 13 groups. The loader rejects unsupported config/version, missing or unexpected weight keys, and incompatible shapes or dtypes. It uses strict state loading and confirms the loaded tensors match the file. The model runs without optimization, quantization, or precision conversion.

The image commands above use this loader together with the unchanged image preprocessing, tiling, boundary rechecks and NMS in inference_engine.py. A minimal Python loading example is:

from model_loader import load_model

model = load_model(device="cpu")  # model.safetensors + model_config.json beside loader

Use predict.py for image/PDF prediction with the complete preprocessing shown above. Initializing the model without pretrained weights creates its architecture locally; every required state tensor is then supplied by the strict safetensors load. The file preserves the original tensor names, shapes, dtypes and values, including its empty boolean buffer. No keys are dropped to deduplicate shared storage.

Outputs and limitations

Outputs are predictions.json, detections.csv, and an annotated PNG per selected page. Boxes are [x1, y1, x2, y2] in full rendered-page pixels: top-left origin, x rightward, y downward. ROI offsets are added back. PDF boxes refer to the renderer's crop/rotation-adjusted raster, not PDF points or CAD units. Image boxes refer to the oriented image pixels.

The CLI has no manual-review interface or reviewed-PDF export. Misses, false detections, duplicates, split double doors, and merged neighboring openings can occur. Dense linework, furniture, legends, faint scans, unusual symbols, scale changes, and unfamiliar drawing styles can reduce performance. It does not automatically exclude schedules or deduplicate repeated sheets. No public benchmark or project-specific performance claim is made. Use human review before relying on counts.

Credits

  • RF-DETR Small, Roboflow: upstream, native base checkpoint, Apache-2.0 licensing. The base was fine-tuned for door openings; this is an independent release without upstream endorsement.
  • FloorPlan-door, ComputerVysion, via Roboflow Universe: dataset, CC BY 4.0. Retained public export metadata identifies v2; exact early subset/version participation is not fully reconstructed.
  • Floor Plans 500, University, via Roboflow Universe: dataset v3, CC BY 4.0. Local export and early training records support v3.

Public dataset data/labels were adapted for a door-only task. Fine-tuning changes the base weights. The dataset licenses are separate from the released model/code licenses; no drawing ownership or additional source permissions are asserted here. No source drawings, training crops, annotations, or evaluation records are distributed.

Downloads last month

-

Downloads are not tracked for this model. How to track
Safetensors
Model size
31.8M params
Tensor type
F32
ยท
BOOL
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support