Train ModelPack 2 can be done by either calling the Python package directly from the virtual environment or, by calling the Docker container. For the sake of simplicity, we are leaving training from eIQ Portal out of this article since it is straightforward and has been documented here.
It is mandatory to have a dataset in darknet format as described in the Datasets for ModelPack section before training the model.
Clone the Playingcards dataset and train the model on it.
git clone https://github.com/DeepViewML/playingcards.git
cd playingcards
dvc pull
In case dvc or dvclive are not installed, please run
pip install dvc dvclive
Those commands above will download the dataset which is ready to be trained.
ModelPack Training Parameters
To have a better idea about command line training parameters just run:
python -m deepview.modelpack.trainer --help
Also, we can list all the parameters in params.yaml file within playingcards folder.
Train ModelPack from Python Package
To train ModelPack from the Python package we must call the entry point with the corresponding parameters in either of the following ways:
python3 -m deepview.modelpack.trainer \
--load=params.yaml \
--dataset=dataset.yaml \
--dvclive=output
or
python3 -m deepview.modelpack.trainer \
--task detection \
--shape 240,320,3 \
--use_power_decoder \
--remove_background_class \
--weights coco \
--batch-size 100 \
--epochs 100 \
--initial_lr 0.01 \
--warmup-epochs 5 \
--warmup_lr 0.0001 \
--dataset dataset.yaml \
--dvclive output \
--compute-anchors
Notice that the license file was not specified via --license parameter because it is already set via the environment variable. See ModelPack License Installation for more details.
Train ModelPack from Docker Container
Train ModelPack from a docker container demands an extra step, mount the dataset as an external volume in the docker run command. This new location of the dataset requires dataset.yaml is modified. Also, dataset.yaml should be relative to the new location used by docker virtual volume, where the dataset files will be located.
docker run -it \
--gpus=all \
--mac-address 02:42:ac:de:ad:01 \
-v `pwd`:/data \
deepview/modelpack:2.2.6 \
--license /data/modelpack.lic \
--task detection \
--shape 240,320,3 \
--use_power_decoder \
--remove_background_class \
--weights coco \
--batch-size 100 \
--epochs 100 \
--initial_lr 0.01 \
--warmup-epochs 5 \
--warmup_lr 0.0001 \
--dataset /data/dataset-docker.yaml \
--dvclive /data/output \
--compute-anchors
Notice that all the paths are absolute relative to the /data folder. This is due to we mounted the current directory into /data volume inside the docker container.
Only one last modification is needed. We need to create the dataset-docker.yaml file. The content will be the same, but this time the path to images and annotations will be the absolute path starting at /data instead of the relative path used when calling the Python package.
Previous (ModelPack Installation) | Home (ModelPack 2) | Next (Datasets for ModelPack) |
Comments
0 comments
Please sign in to leave a comment.