Downloads ยท 30 days
101
19% of all-time downloads
negi3961/factory-defect-guard
factory-defect-guard is a object detection model from negi3961. Use it when you need objects located in an image. It is set up for ultralytics. The card lists the license as mit.
Multi-domain industrial defect detection model trained on 29,000+ images across steel surfaces, PCBs, and industrial components. Detects 17 defect classes in a single forward pass.
Downloads ยท 30 days
101
19% of all-time downloads
All-time downloads
543
Public
Repo size
119 MB
Likes
0
Public
Click a slice to open those files.
.pt45.1 MB ยท 100%
From the Hugging Face model README
Multi-domain industrial defect detection model trained on 29,000+ images across steel surfaces, PCBs, and industrial components. Detects 17 defect classes in a single forward pass.
| Metric | Value |
|---|---|
| [email protected] | 83.0% (V6_MC) |
| [email protected]:0.95 | 56.4% |
| Precision | 78.8% |
| Recall | 72.2% |
| Model size | 22.5 MB |
| Input size | 640ร640 |
Steel Surface (NEU Dataset)
crazing ยท inclusion ยท patches ยท pitted_surface ยท rolled_in_scale ยท scratches
PCB Defects
pcb_missing_hole ยท pcb_mouse_bite ยท pcb_open_circuit ยท pcb_short ยท pcb_spur ยท pcb_spurious_copper
Industrial Components (MVTec-derived)
metal_nut_defect ยท screw_defect ยท transistor_defect ยท tile_defect ยท cable_defect
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
# Load model
model_path = hf_hub_download(
repo_id = "negi3961/factory-defect-guard",
filename = "best_v6_mc.pt" # MC Dropout version โ best accuracy
)
model = YOLO(model_path)
# Run inference
results = model.predict("your_image.jpg", conf=0.25)
results[0].show()
# Get detections
for box in results[0].boxes:
cls = int(box.cls)
conf = float(box.conf)
name = model.names[cls]
print(f"{name}: {conf:.2f}")
| File | Description | [email protected] |
|---|---|---|
best_v6_mc.pt | Recommended โ V6 fine-tuned with MC Dropout | 0.830 |
best.pt | V6 base model | 0.796 |
Use best_v6_mc.pt for production. best.pt is kept for reproducibility.
| Dataset | Domain | Images |
|---|---|---|
| NEU Surface Defect Database | Steel surface | ~1,800 |
| PCB Defect (akhatova) | PCB original | ~1,600 |
| PCB Dataset (nakul8820) | PCB augmented | ~2,000 |
| PCB Defect (norbertelter) | PCB YOLO format | ~10,668 |
| MVTec AD subset | Industrial objects | ~428 |
| Magnetic Tile Defects | Tile surface | ~2,688 |
| Surface Defect (yidazhang07) | Mixed | ~4,194 |
| Total | ~29,354 |
model: YOLOv8s
epochs: 60
imgsz: 640
batch: 16
optimizer: AdamW
lr0: 0.0001
mosaic: 1.0
mixup: 0.2
patience: 20
platform: Kaggle GPU (Tesla T4)
| Run | Epochs | [email protected] | Notes |
|---|---|---|---|
| V5 | 43 | 0.7477 | Initial training |
| V6 | 60 | 0.7960 | Full run, AdamW |
| V6_MC | +fine-tune | 0.8300 | MC Dropout added |
| Class | [email protected] |
|---|---|
tile_defect | 99.5% |
pcb_missing_hole | 99.3% |
pcb_short | 95.5% |
pcb_open_circuit | 90.7% |
patches | 91.6% |
pcb_spurious_copper | 91.1% |
pcb_mouse_bite | 81.8% |
metal_nut_defect | 85.5% |
inclusion | 81.3% |
scratches | 80.7% |
cable_defect | 82.3% |
rolled_in_scale | 57.4% |
screw_defect | 56.8% |
transistor_defect | 54.0% |
crazing | 48.9% |
Note:
crazingis the hardest class โ subtle surface texture variation makes it difficult to detect.tile_defectachieves near-perfect accuracy due to strong visual contrast.
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
import cv2
CLASSES = [
'crazing', 'inclusion', 'patches', 'pitted_surface',
'rolled_in_scale', 'scratches', 'pcb_missing_hole',
'pcb_mouse_bite', 'pcb_open_circuit', 'pcb_short',
'pcb_spur', 'pcb_spurious_copper', 'metal_nut_defect',
'screw_defect', 'transistor_defect', 'tile_defect', 'cable_defect'
]
model_path = hf_hub_download("negi3961/factory-defect-guard", "best_v6_mc.pt")
model = YOLO(model_path)
def inspect(image_path, conf_threshold=0.25):
results = model.predict(image_path, conf=conf_threshold, verbose=False)
detections = []
for box in results[0].boxes:
detections.append({
"class": CLASSES[int(box.cls)],
"confidence": round(float(box.conf), 3),
"bbox": box.xyxy[0].tolist()
})
return detections
print(inspect("surface_sample.jpg"))
ultralytics>=8.0.0
huggingface_hub
torch>=2.0.0
Pillow
opencv-python
crazing and transistor_defect classes have lower accuracy (~49โ54%) and may produce false negatives on ambiguous texturesNegi โ ML Engineer
HuggingFace: @negi3961