Docker usage and local Yolov5 packaging tutorial

1. Docker installation

Note: The official also provides direct channels for Pulling Yolov5:

docker pull ultralytics/yolov5

For details, see: https://hub.docker.com/r/ultralytics/yolov5 

-------------------------------------------------- The following text------------------------------------------------ -----

It is recommended to watch this teaching video: 05. Installation and configuration_bilibili_bilibili

Official download link: Docker: Accelerated Container Application Development

Note: You need to register an account scientifically online

After downloading, the picture is as follows:

2. Learning related instructions of Docker

Comprehensive list of common docker commands_Common docker commands_Protect our fat tiger's blog-CSDN blog

[Docker Series] Learn Docker from scratch - Detailed explanation of docker run command_Why go to the blog to learn-CSDN blog

3. Case - Packaging the locally modified Yolov5 package

3.1 Find the local Yolov5 folder:

3.2 Create Dockerfile. Note that there is no extension.

#基于的基础镜像
FROM python:3.9.10
#代码添加到code文件夹
ADD . /usr/src/app/uniform/yolotest
# 设置code文件夹是工作目录
WORKDIR /usr/src/app/uniform/yolotest
# 安装支持
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ -r requirements.txt

3.3 Create Image in the cmd of the Yolov5 project directory

docker build -t test .

The running time may be relatively long. The interface after the running is completed:

You can see it in Docker Desktop:

3.4 Convert Image to Container

run in cmd:

docker run -it --gpus all --net=host --ipc=host --privileged=true --name test01 --ulimit core=-1 -v F:/Deep_learning/Dockertest01:/usr/src/app/uniform/data test env LANG=C.UTF-8 /bin/bash 

For specific meanings, please refer to: [Docker series] Learn Docker from scratch—docker run command detailed explanation

Now the CMD interface is:

That is, the creation is successful. You can try to call Python to test whether torch's cuda is available:

 

3.5 Import weight files and test photos to Container and test Yolov5

Browse the Yolov5 file directory in Docker Desktop and import the pt weight file and photo you want to test:

Just drag the pt file and test photo in:

Run yolov5 for detection:

python detect.py --weights tomato.pt --source xs_4.jpg --conf-thres 0.7

Finish: 

Guess you like

Origin blog.csdn.net/Father_of_Python/article/details/132731942