Downloads · 30 days
0
darius-muc/YOLOv7_Window_Detection_with_Measurements
YOLOv7_Window_Detection_with_Measurements is a machine learning model from darius-muc. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A YOLOv7 model fine-tuned for detecting windows with dimensional measurements in architectural drawings.
Downloads · 30 days
0
Access
Public
Updated Dec 25, 2025
Repo size
74.8 MB
Likes
0
Public
Click a slice to open those files.
.pt74.8 MB · 100%
From the Hugging Face model README
A YOLOv7 model fine-tuned for detecting windows with dimensional measurements in architectural drawings.
This model is a fine-tuned YOLOv7 object detector specialized for the window manufacturing industry. It automatically detects and locates windows with dimensional measurements in order documents, proposals, and technical drawings.
The model enables window manufacturers to:
Model Type: Object Detection (YOLOv7)
Industry: Window Manufacturing & Installation
Task: Window boundary detection in order documents and technical drawings
Classes: 1 (window)
The model was trained on a custom dataset of architectural drawings containing:
All images were manually annotated using labelImg with bounding boxes around windows. The dataset includes various drawing styles, scales, and quality levels to ensure robust detection.
Base Model: YOLOv7 (pre-trained weights: yolov7_training.pt)
Training Approach: Transfer learning / Fine-tuning
Configuration:
Final Performance Metrics:
This model was specifically created for window manufacturers and their business partners to automate the processing of window orders and proposals. The model detects window boundaries with visible measurements in technical drawings and order documents, enabling:
pip install torch torchvision
git clone https://github.com/WongKinYiu/yolov7.git
cd yolov7
import torch
from models.experimental import attempt_load
from utils.general import non_max_suppression, scale_coords
from utils.datasets import letterbox
import cv2
import numpy as np
# Load model
device = torch.device('cpu') # or 'cuda:0' for GPU
model = attempt_load('window_with_measurements_best.pt', map_location=device)
model.eval()
# Prepare image
img_path = 'your_drawing.jpg'
img0 = cv2.imread(img_path)
img = letterbox(img0, 640, stride=32)[0]
img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x640x640
img = np.ascontiguousarray(img)
img = torch.from_numpy(img).to(device)
img = img.float() / 255.0
if img.ndimension() == 3:
img = img.unsqueeze(0)
# Inference
with torch.no_grad():
pred = model(img)[0]
pred = non_max_suppression(pred, 0.25, 0.45)
# Process detections
for det in pred:
if len(det):
det[:, :4] = scale_coords(img.shape[2:], det[:, :4], img0.shape).round()
for *xyxy, conf, cls in det:
label = f'window {conf:.2f}'
print(f"Detected: {label} at {xyxy}")
# Draw bounding box
cv2.rectangle(img0, (int(xyxy[0]), int(xyxy[1])),
(int(xyxy[2]), int(xyxy[3])), (0, 255, 0), 2)
cv2.putText(img0, label, (int(xyxy[0]), int(xyxy[1])-10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
# Save result
cv2.imwrite('result.jpg', img0)
import glob
from pathlib import Path
# Process multiple order documents
order_paths = glob.glob('orders/*.jpg')
for order_path in order_paths:
# Run inference (use code above)
# Save results to output directory
pass
import os
def extract_windows_from_order(image_path, output_dir):
"""
Extract individual windows from an order document for processing.
Useful for separating windows for perimeter calculation, quoting, etc.
"""
# Load and run inference (use inference code above)
img0 = cv2.imread(image_path)
# ... run detection ...
# Extract each detected window
for idx, (*xyxy, conf, cls) in enumerate(det):
# Crop window region
x1, y1, x2, y2 = map(int, xyxy)
window_crop = img0[y1:y2, x1:x2]
# Save individual window
window_filename = f"{Path(image_path).stem}_window_{idx+1}.jpg"
cv2.imwrite(os.path.join(output_dir, window_filename), window_crop)
# Optional: Calculate bounding box dimensions for perimeter
width_px = x2 - x1
height_px = y2 - y1
print(f"Window {idx+1}: {width_px}x{height_px} pixels")
# Usage
extract_windows_from_order('order_12345.jpg', 'extracted_windows/')
Hardware: CPU (Mac)
Training Time: ~23.4 hours for 300 epochs
Framework: PyTorch 2.8.0
YOLOv7 Repository: WongKinYiu/yolov7
This model is released under the GPL-3.0 License (inherited from YOLOv7).
For commercial use, please review the YOLOv7 license terms and ensure compliance.
If you use this model in your research or project, please cite:
@misc{yolov7-window-detection,
title={YOLOv7 Window Detection with Measurements},
author={Your Name},
year={2025},
howpublished={\url{https://huggingface.co/your-username/yolov7-window-detection}}
}
And the original YOLOv7 paper:
@article{wang2022yolov7,
title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
journal={arXiv preprint arXiv:2207.02696},
year={2022}
}
Developed by: Modernaus Ugdymo Centras (MUC)
Website: https://muc.lt
For questions, collaboration opportunities, or to learn more about our AI solutions for the window manufacturing industry, please visit our website or contact us through the channels listed there.