A modern, AI-powered web application for PCB defect detection using YOLOv8 and Streamlit
Developed by Raj Patel
- π Advanced Defect Detection: Upload single or multiple PCB images for AI-powered defect analysis
- π Batch Processing: Process multiple images simultaneously with comprehensive analytics
- π Interactive Analytics: Visualize defect distributions with interactive charts and statistics
- πΎ Download Results: Export all defect-annotated images as a ZIP archive
- π¨ Modern UI: Clean, glassmorphism-inspired responsive interface
- β‘ High Performance: Powered by finetuned YOLOv8 model for accurate detection
- π Cross-Platform: Works seamlessly on Windows, Linux (Ubuntu), and Streamlit Cloud
- π₯οΈ GPU Support: Automatic GPU acceleration when available (CUDA compatible)
clean_project/
βββ π src/
β βββ π web_interface.py # Main Streamlit web interface
β βββ π§ model.py # YOLOv8 model and detection logic
β βββ π __init__.py # Package initialization
βββ π€ model/
β βββ pcb_defect_detection_finetuned.pt # Trained YOLOv8 model
βββ π data/
β βββ data.yaml # Dataset configuration
βββ π main.py # Application entry point
βββ π requirements.txt # Python dependencies
βββ βοΈ config.yaml # Application configuration
βββ π README.md # Project documentation
| Component | Technology | Version |
|---|---|---|
| Frontend | Streamlit | 1.28+ |
| AI Model | YOLOv8 (Ultralytics) | Latest |
| Deep Learning | PyTorch | 2.0+ |
| Image Processing | OpenCV | 4.8+ |
| Data Visualization | Plotly | 5.0+ |
| Data Handling | Pandas, NumPy | Latest |
| Configuration | PyYAML | Latest |
streamlit # Web application framework
ultralytics # YOLOv8 model and utilities
opencv-python # Image processing and computer vision
numpy # Numerical computing
pillow # Image I/O operations
matplotlib # Plotting and visualization
plotly # Interactive charts and graphs
pyyaml # Configuration file parsing
pandas # Data manipulation and analysistorch # Deep learning framework (GPU/CPU)
torchvision # Computer vision utilities
supervision # Advanced annotation tools
tqdm # Progress bars for traininggit clone https://github.com/R204570/PCB_DEFECT_DETECTION.gitcd PCB_DEFECT_DETECTION
python -m venv venv
venv\Scripts\activatecd PCB_DEFECT_DETECTION
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txt# Install PyTorch with CUDA support (adjust version as needed)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt
# Run the application
streamlit run main.pyThe application will open in your browser at http://localhost:8501
- Push your repository to GitHub
- Connect your GitHub repo to Streamlit Cloud
- Set the entry point to
PCB_DEFECT_DETECTION/main.py - Deploy and share your app!
- Model Type: YOLOv8 (You Only Look Once v8)
- Training Data: Custom PCB defect dataset
- Model File:
model/pcb_defect_detection_finetuned.pt - Input Size: Configurable (default: 640x640)
- Supported Defects: Multiple PCB manufacturing defects
- Performance: Optimized for real-time inference
- Navigate to the "Single Analysis" tab
- Upload a PCB image
- Adjust detection parameters if needed
- View detection results with bounding boxes
- Download annotated image
- Go to the "Batch Processing" tab
- Upload multiple PCB images (max 10)
- Monitor processing progress
- View defect analytics and distribution charts
- Download all annotated images as ZIP
- Use the "Live Capture" tab
- Take photos using your device camera
- Get real-time defect detection results
The application can be customized through config.yaml:
model:
confidence_threshold: 0.25
nms_threshold: 0.4
input_size: [640, 640]
data:
batch_size: 16
output_path: "output"
training:
epochs: 100| Issue | Solution |
|---|---|
| Missing model file | Ensure model/pcb_defect_detection_finetuned.pt exists |
| CUDA not available | App automatically falls back to CPU |
| Slow inference | Use GPU-enabled installation for faster results |
| ModuleNotFoundError | Verify virtual environment and requirements installation |
| Streamlit Cloud errors | Check repository size and file structure |
- Inference Speed: ~50ms per image (GPU), ~200ms per image (CPU)
- Accuracy: mAP@0.5 > 85% on test dataset
- Supported Formats: JPG, PNG, BMP
- Max Image Size: 4096x4096 pixels
- Batch Processing: Up to 10 images simultaneously
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Raj Patel
- π LinkedIn Profile
- π― AI/ML Learner
- π Passionate about AI
- Ultralytics for the YOLOv8 framework
- Streamlit for the amazing web app framework
- OpenCV for computer vision capabilities
- PyTorch for deep learning infrastructure