🔹 Solar Panel Defect Detection using YOLOv9c-seg
This project focuses on detecting and segmenting surface defects in solar panels using the YOLOv9c-seg model.
The primary objective is to automate the inspection process and improve the efficiency and accuracy of identifying defective panels, reducing manual labor and maintenance downtime.
- Develop a robust defect detection model for solar panels using YOLOv9c-seg.
- Segment defective regions with high accuracy to support maintenance planning.
- Evaluate model performance across multiple defect classes.
- Deploy an interactive application for visualizing defect detection results.
- Source: Custom dataset prepared using Roboflow.
- Total Images: 1,500+ labeled images.
- Classes: 6 defect categories — Bird-drop, Defective, Dusty, Electrical-Damage, Non-Defective, Physical-Damage.
- Structure:
train/
images/
labels/
val/
images/
labels/
test/
images/
labels/
| Category | Tools / Libraries |
|---|---|
| Programming | Python |
| ML Framework | YOLOv9c-seg, PyTorch |
| Data Handling | Pandas, NumPy |
| Visualization | OpenCV, Matplotlib |
| Deployment | Streamlit |
| Version Control | Git, GitHub |
- Data Preprocessing: Data cleaning, augmentation, and annotation via Roboflow.
- Model Training: Used YOLOv9c-seg for image segmentation and trained with early stopping.
- Evaluation: Measured performance using mAP@50, Precision, and Recall metrics.
- Deployment: Built a Streamlit web app to visualize real-time defect detection and segmentation results.
solar-panel-defect-detection/
│
├── app/
│ ├── app.py # Streamlit web application
│ ├── requirements_app.txt # (Optional) app-specific dependencies
│
├── train/
│ ├── Train_Solaryolov9.ipynb # Model training notebook (Google Colab)
│ ├── requirements_train.txt # (Optional) training dependencies
│
├── yolov9_best.pt # Trained YOLOv9 model weights
├── requirements.txt # Combined environment dependencies
├── README.md # Project documentation (this file)
└── data.yaml # Data yaml file
Clone the repo
git clone https://github.com/arshiakauser/Solar-Panel-Defect-Detection.git Navigate into the project folder
cd solar-panel-defect-detectionYou can set up one environment for both training and running the app.
🧩 1. Create and Activate Environment
#Create a virtual environment
python -m venv solar_env
#Activate environment
# Windows:
solar_env\Scripts\activate
# macOS/Linux:
source solar_env/bin/activate📦 2. Install Dependencies
Install all dependencies from the combined file:
pip install -r requirements.txtExample requirements.txt:
ultralytics==8.2.77
streamlit
opencv-python
pillow
numpy
matplotlib
torch
torchvision
torchaudio
jupyter
pandas
To Run Locally:
cd train
jupyter notebook Train_Solaryolov9.ipynb- Update dataset paths and parameters as needed.
- Train the model.
- Export the best model as yolov9_best.pt and move it to the project root.
Dataset Structure:
- Ensure your dataset is structured as:
dataset/
├── train/
│ ├── images/
│ └── labels/
├── val/
│ ├── images/
│ └── labels/
├── test/
│ ├── images/
│ └── labels/
└── data.yaml
| Metric | Bounding Box(B) | Segmentation Mask (M) |
|---|---|---|
| Precision | 0.786 | 0.779 |
| Recall | 0.715 | 0.689 |
| mAP@50 | 0.776 | 0.736 |
| mAP@50-95 | 0.583 | 0.501 |
- Data augmentation improved model generalization on unseen solar panel samples.
- Learned optimization of YOLOv9c parameters for better segmentation accuracy.
- Integrated computer vision models with a user-friendly dashboard using Streamlit.
- Managing annotation quality for small defect regions.
- Balancing dataset across multiple defect classes.
- Ensuring smooth inference during real-time deployment.
Run Streamlit App Locally:
cd app
streamlit run app.pyApp Features:
- Upload and preview solar panel images
- Real-time defect detection using trained YOLOv9 model
- Class-wise count of detected defects
- Download annotated output (optional)
- User-friendly and responsive Streamlit UI
| Original Image | Detected Output |
|---|---|
![]() |
![]() |
Detected Classes Example:
- Bird Drop: 17
- Defective: 6
App Link: 🔸 http://localhost:8501/
Demo Video: 🔸
The YOLOv9c-seg model achieved 77% mAP@50, efficiently detecting multiple types of defects in solar panels with accurate segmentation. The Streamlit dashboard enables easy visualization and inspection support for maintenance engineers.
- Name: Arshia Kauser Shahzaan
- LinkedIn: linkedin.com/in/arshiakauser
- GitHub: github.com/arshiakauser
- Email: 🔸(Optional — add your professional email)
🪪 License
This project is open-source and available under the MIT License.
- Dataset preparation support via Roboflow
- YOLOv9c-seg implementation by Ultralytics community
- Streamlit for enabling interactive AI app deployment

