This repository contains a keras AI model trained to detect crops and vegetation in images of vegetable-gardens ("orto" in italiano) taken perpendicular to the terrain. The model is accessible via an installable python module: crop_detection
.
- Install OpenCV with Python 3 support
import cv2
must work without throwing exceptions- on Raspberry either compile from source, or
sudo apt-get install libatlas3-base
and then letsetup.py
installopencv-python
- you may also need this on raspberry:
sudo apt install libatlas-base-dev
- Install TensorFlow >=2.4.0
- on Raspberry use this repo
- Don't worry if TensorFlow and OpenCV require different versions of numpy, just make sure the latest one is installed and ignore pip warnings
- The
setup.py
file can be used to install the module: just runpython3 -m pip install .
in the root directory- It will take care of installing the needed dependencies (OpenCV and TensorFlow), but on Raspberry it won't work as explained above
- Note:
pip
may give some warnings that can be solved by appending--use-feature=in-tree-build
to the command, but they can be ignored
crop_detection/
is a Python 3 module that can be imported or installedconverters/
contains scripts useful to build a dataset in thedataset/
folder, see Using the convertersdataset/
will contain, once generated, training and validation data with both images and labelsdatasets_raw/
contains the raw datasets you will downloaddatasets_raw/cyberorto/
contains images taken by MindsHub's cyberorto, along with scripts that generate labels based on pixel color heuristics (see thegenerators/cyberorto_*.py
scripts)models/
contains some trained models, see Model nametraining/
contains scripts that instantiate a new model, train it and perform data augmentationvisualizers/
contains scripts that help visualize what is happening and the performance of the various models
The model name is like this: model_INPUTHEIGHTxINPUTWIDTH_DATASETVERSION_EPOCH.hd5
INPUTHEIGHTxINPUTWIDTH
represents the size of the input image, e.g.352x480
DATASETVERSION
identifies the raw datasets used to create the training dataset:1
: ijrr_sugarbeets, synthetic_sugarbeat_random_weeds2
: ijrr_sugarbeets, synthetic_sugarbeat_random_weeds, cwfid3
: ijrr_sugarbeets, synthetic_sugarbeat_random_weeds, cwfid, cyberorto, ews
EPOCH
is the number of epochs the model was trained for, e.g.10
Choose some datasets you want to use from the list below, then download them and unpack them in the datasets_raw/
subfolder (which you will need to create) in the repo's root. Then you can run python3 converters/converter_DATASET_NAME.py
to create (part of) a training dataset with both training/
and validation/
images in the dataset/
subfolder.
-
synthetic_sugarbeat_random_weeds
- Synthetic dataset - sugarbeets (380MB)
paper(link not working anymore)- download synthetic_sugarbeet_random_weeds.tar.gz, move it in the
datasets_raw/
subfolder and unpack it
-
ijrr_sugarbeets_2016_annotations
- Bonirob dataset - sugarbeets (5TB)
- website
- using only
part01
is more than enough (2GB) - download ijrr_sugarbeets_2016_annotations.part01.rar, move it in the
datasets_raw/
subfolder and unpack it withunrar x ijrr_sugarbeets_2016_annotations.part01.rar
(it will give an error at the end about other parts of the RAR archive missing, ignore it)
-
cwfid
- CWFID - Crop Weed Field Image Dataset - carrots (80MB)
- paper
- run
git clone https://github.com/cwfid/dataset
in thedatasets_raw/
subfolder
-
cyberorto
- images taken by MindsHub's Cyberorto
- there are some scripts that generate labels based on pixel color heuristics (see the
datasets_raw/cyberorto/generators/cyberorto_*.py
scripts)
-
ews
- Eschikon Wheat Segmentation (50MB)
- paper
- download EWS-Dataset.zip, move it in the
datasets_raw/
subfolder, unpack it and finally rename the newly createdEWS-Dataset
folder toews
Aberystwyth Leaf Evaluation Dataset (62GB)not useful but still noteworthyPlantVillage Datasetleaf classification not on soil
This is the actually used tutorial and model: Segmentation tutorial 4 (custom keras)
SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation
SegNet tutorial 1 (custom caffe)
- Repo with models
- Caffe - Deep learning framework -
sudo apt install caffe-cpu
Segmentation tutorial 3 (keras-segmentation)
Fast and Accurate Crop and Weed Identification with Summarized Train Sets for Precision Agriculture