This project focuses on detecting and counting superworms in images using various computer vision and machine learning techniques, including image processing with OpenCV, Convolutional Neural Networks (CNN), and YOLO object detection models.
sampleCounter.py
: Script for counting superworms using contour detection in images.trainedCNN.py
: Script for training a CNN model to count objects in images.- Various image files (1.jpg, 2.jpg, etc.): Sample images for testing.
- Python 3.x
- OpenCV (cv2)
- TensorFlow
- NumPy
- Matplotlib
- scikit-learn
Install dependencies using:
pip install opencv-python tensorflow numpy matplotlib scikit-learn
Run sampleCounter.py
to count superworms in an image using image processing:
python sampleCounter.py
This will process '26.jpg' and display the thresholded image and contours.
Run trainedCNN.py
to train a CNN model for counting objects:
python trainedCNN.py
Note: This script uses synthetic data for demonstration.
The project includes a small COCO8-seg dataset for segmentation tasks with YOLOv8. It contains 8 images (4 train, 4 val) with annotations. Note: Dataset files are ignored in version control. To use the dataset, download it from the Ultralytics COCO8-seg repository.
Processed images and screenshots are saved in the result/
folder. Note: Result files are ignored in version control as they are generated outputs.
To run the project, you may need to:
- Install dependencies as listed.
- Obtain sample images or use your own for testing.
- Train models using the provided scripts or download pre-trained ones.
- Download datasets if needed.
- Ensure image paths are correct before running scripts.
- Model training may require GPU for better performance.
- The CNN training script uses synthetic data; replace with real data for production use.
- OpenCV: https://opencv.org/
- TensorFlow: https://www.tensorflow.org/
- YOLOv5: https://github.com/ultralytics/yolov5
- COCO Dataset: https://cocodataset.org/