This repository contains tools and deep learning models for stressed crop detection through image segmentation.
src/: Contains all the source code for data preparation, model training, and inference.main.py: Entry point for training and evaluation.inference.py: Script to run inference on new images.cv_masking.py: OpenCV script for generating yellow color masks.network.py: PyTorch models (U-Net, R2U-Net, AttU-Net, R2AttU-Net).dataset.py&data_loader.py: Utilities for preparing datasets.solver.py: Core logic for training and evaluation loop.
weights/: Contains pre-trained PyTorch model weights (.ptor.pkl).
Ensure you have PyTorch, torchvision, and OpenCV installed:
pip install torch torchvision opencv-python Pillow numpyGenerate a yellow-color mask (e.g., for stressed regions) using OpenCV:
python src/cv_masking.py --input path/to/images --output ./masksTo train the segmentation models, arrange your dataset into a directory and run:
python src/main.py --mode train --model_type U_Net --train_path ./dataset/train/ --valid_path ./dataset/valid/(Available models: U_Net, R2U_Net, AttU_Net, R2AttU_Net)
Run inference on new images using a trained model weight file:
python src/inference.py --input path/to/image_or_folder --output ./results --model_type U_Net --weights weights/model_checkpoint1.ptBased on image segmentation architectures such as U-Net and its attention/recurrent variants.