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.
1 from huggingface_hub import hf_hub_download
2 from ultralytics import YOLO
3
4 # Load model
5 model_path = hf_hub_download (
6 repo_id = "negi3961/factory-defect-guard" ,
7 filename = "best_v6_mc.pt" # MC Dropout version — best accuracy
8 )
9 model = YOLO ( model_path )
10
11 # Run inference
12 results = model . predict ( "your_image.jpg" , conf = 0.25 )
13 results [ 0 ] . show ( )
14
15 # Get detections
16 for box in results [ 0 ] . boxes :
17 cls = int ( box . cls )
18 conf = float ( box . conf )
19 name = model . names [ cls ]
20 print ( f" { name } : { conf : .2f } " )
1 model : YOLOv8s
2 epochs : 60
3 imgsz : 640
4 batch : 16
5 optimizer : AdamW
6 lr0 : 0.0001
7 mosaic : 1.0
8 mixup : 0.2
9 patience : 20
10 platform : Kaggle GPU (Tesla T4)
1 from huggingface_hub import hf_hub_download
2 from ultralytics import YOLO
3 import cv2
4
5 CLASSES = [
6 'crazing' , 'inclusion' , 'patches' , 'pitted_surface' ,
7 'rolled_in_scale' , 'scratches' , 'pcb_missing_hole' ,
8 'pcb_mouse_bite' , 'pcb_open_circuit' , 'pcb_short' ,
9 'pcb_spur' , 'pcb_spurious_copper' , 'metal_nut_defect' ,
10 'screw_defect' , 'transistor_defect' , 'tile_defect' , 'cable_defect'
11 ]
12
13 model_path = hf_hub_download ( "negi3961/factory-defect-guard" , "best_v6_mc.pt" )
14 model = YOLO ( model_path )
15
16 def inspect ( image_path , conf_threshold = 0.25 ) :
17 results = model . predict ( image_path , conf = conf_threshold , verbose = False )
18 detections = [ ]
19 for box in results [ 0 ] . boxes :
20 detections . append ( {
21 "class" : CLASSES [ int ( box . cls ) ] ,
22 "confidence" : round ( float ( box . conf ) , 3 ) ,
23 "bbox" : box . xyxy [ 0 ] . tolist ( )
24 } )
25 return detections
26
27 print ( inspect ( "surface_sample.jpg" ) )
ultralytics>=8.0.0
huggingface_hub
torch>=2.0.0
Pillow
opencv-python