背景介绍
果园水果的检测、计数和定位是农业自动化中的重要任务。它们允许农民管理和优化资源,并在收获期间做出明智的决定。水果检测和定位也是自动采摘的前提,这是劳动密集型的过程之一。
模型介绍
这篇博文中选用MaskRcnn作为基准模型,模型原理参考这里。
数据下载
https://conservancy.umn.edu/handle/11299/206575
深度学习环境配置
dockerfile
# 继承PyTorch的cuda镜像
FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel
LABEL maintainer = "xxxxxx@qq.com"
LABEL version = "0.2"
LABEL description = "prepare deep learning environment"
# 指定docker镜像中,默认的工作路径是/app
WORKDIR /app
RUN rm /etc/apt/sources.list.d/cuda.list \
&& rm /etc/apt/sources.list.d/nvidia-ml.list \
&& apt-get update \
&& apt-get install -y libgl1 \
&& conda install libgdal=3.4.1 gdal==3.4.1 tiledb=2.2 \
&& pip config set global.index-url https://pypi.douban.com/simple/ \
&& pip install opencv-python-headless==4.6.0.66 \
opencv-python==4.6.0.66 \
easycython==1.0.7 \
cython==0.29.30 \
pretrainedmodels==0.7.4 \
efficientnet-pytorch==0.6.3 \
segmentation-models-pytorch==0.2.1 \
scipy>=1.4.1 \
path==16.4.0 \
scikit-image==0.15.0 \
scikit-learn==0.21.3 \
pytorch_toolbelt==0.5.0 \
prefetch_generator \
pycocotools==2.0.5
使用方法
源码下载
链接:https://pan.baidu.com/s/1FrcYlcXvre35xSchYR32yQ
提取码:ds73
容器构建
cd docker
docker build -t dl/training:latest .
docker run -it --gpus all -v ${your project root}:${container root} dl/training:latest
训练
python train_rcnn.py --data_path /data --model maskrcnn --epochs 50 --output-dir /segmentation/results
预测
python train_rcnn.py --data_path /data --model maskrcnn --epochs 50 --output-dir /segmentation/results