/YOLOv5-GradCAM

SKKU S-HERO Capstone Projects with PCB detection using Yolov5&Grad-CAM

Primary LanguagePythonMIT LicenseMIT

YOLOv5-GradCAM

SKKU S-HERO Capstone Project with PCB defects detection
using YOLOv5 & GradCAM (Pytorch)

YOLOv5 Source: https://github.com/ultralytics/yolov5
Grad-CAM Source: https://github.com/jacobgil/pytorch-grad-cam

Usage

1. Object Detection using YOLOv5

  • Check 'yolov5' folder, read usage first
  • Structure your files as yolov5's input
  • Run train.py for training
  • and detect.py to save detection results (if you're not interesting at interpreting results, you can skip from here.)

2. Interpret classification results using grad-CAM

2-1. Train YOLOv5_classifier

  • We're interpreting classification results only, not including detection
  • Run train.py for training yolo_classifier: submodel of yolov5 with detecting architecture removed
  • Make sure you use the same structure as yolov5 (s, m, l, x).
  • Classification results will be SAME between original yolo and yolo_classifier

2-2. Run cam.py

  • In 'pytorch-grad-cam' folder
  • Modify 'model' to the same model as you used before
  • Modify 'ckpt' to your own trained weight
  • Run script(check pytorch-grad-cam usage)

Detection & GradCAM results

A2 KakaoTalk_20211106_204417278 A2_cam

B2 KakaoTalk_20211106_204417278_03 B2_cam