Nvidia based docker image with Darknet to train a yolov3-tiny network on your custom images
Works seemlesly with AWS EC2 and S3
- Create a S3 bucket on AWS
- Upload images, train.txt and test.txt lists to the S3 bucket. Expected structure of the bucket
your-s3-bucket/
└── data/
├── train.txt
├── test.txt
├── images/
| ├── image-name-1.jpg
| ├── image-name-2.jpg
| └── ...
└── labels/
├── image-name-1.txt
├── image-name-2.txt
└── ...
train.txt
and test.txt
should contain image relative paths to the data/ folder in S3, ex.
data/images/image-name-1.jpg
data/images/image-name-2.jpg
-
Modify
coco.names
,config.data
andyolov3-tiny.cfg
as described by https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects -
Set up your EC2 instance
- Create a custom role in IAM settings for EC2, which allows access to your S3 bucket.
- Create a GPU instance on AWS which already has NVIDIA and CUDA pre-installed. Search for "Deep Learning" when choosing your instance AMI
- Ensure you set your created role as an IAM role of the instance
- SSH into the instance. More info
- clone this repo
git clone https://github.com/deividasskiparis/aws-darknet-yolo-docker.git aws-darknet-yolo-docker && cd aws-darknet-yolo-docker
-
Build docker image
docker build --build-arg S3=your-s3-bucket-name -t train-yolo .
- Run image
docker run -d --runtime=nvidia --name=train-yolo train-yolo
NOTE: If running locally instead on EC2, you will have to provide AWS credentials to your docker container for a role, that has access to your S3 bucket
docker run -d --runtime=nvidia --name=train-yolo -e "AWS_ACCESS_KEY_ID=*********" -e "AWS_SECRET_ACCESS_KEY=*********" train-yolo
-
After the training is finished, the trained weights will be uploaded to you S3 bucket
/models
directory -
Terminate your EC2 after the training is finished to avoid charges