The following are the detailed steps to build a yolov5 development environment using Docker:
1. Install Docker
If you have not installed Docker on your computer, you can install it according to the instructions on the Docker official website.
2. Download yolov5 code
Before starting, you need to download the code of yolov5 to the local. The code can be cloned locally with the following command:
git clone https://github.com/ultralytics/yolov5.git
3. Build Docker image
In the yolov5 code directory, there is a Dockerfile file, which we can use to build a yolov5 Docker image. Enter the code directory of yolov5 in the terminal, and then execute the following command:
docker build -t yolov5 .
This builds a Docker image named "yolov5" according to the instructions in the Dockerfile.
4. Run the Docker container
After building the Docker image, we can start a new Docker container with the following command:
docker run -it --name yolov5 --gpus all -v /path/to/local/directory:/yolov5 ultralytics/yolov5:latest bash
Among them, "/path/to/local/directory" should be replaced with the path of your local yolov5 code directory.
This command will start a new Docker container named "yolov5", and mount the local yolov5 code directory to the "/yolov5" directory in the container. In addition, GPU acceleration will also be enabled. If your computer does not have a GPU, you do not need to add the "--gpus all" parameter.
5. Run yolov5 in a Docker container
After starting the Docker container, we can use yolov5 in the container. After entering the container, execute the following command in the terminal to run the sample code of yolov5:
cd /yolov5 python detect.py --source 0
This turns on the camera and uses yolov5 for real-time object detection.
I hope this step of using Docker to build a yolov5 development environment will help you. If you have trouble using Docker, you can check out the official Docker documentation or ask for help in communities like Stack Overflow.
other:
pull image
sudo docker pull pytorch/pytorch:latest
create container
sudo docker run -it -d --gpus "device=0" pytorch/pytorch bash
view all containers
sudo docker ps -a
View running containers
sudo docker ps
into the container
docker start -i container ID
Import all dependent packages into requirements.txt,
Install dependencies
#pip install -r ./requrements.txt
github project:
GitHub - xialuxi/yolov5_face_landmark: face detection based on yolov5, with key point detection
Common docker commands:
docker images view image
docker rmi image-id delete image
docker ps -a to view all containers
docker rm container-id delete container