@@ -20,7 +20,7 @@ This directory provides a SparseML integrated training script for the popular
2020repository.
2121
2222Using this integration, you will be able to apply SparseML optimizations
23- to the powerful training flows provided in the yolov5 repository.
23+ to the powerful training flows provided in the ` yolov5 ` repository.
2424
2525Some of the tasks you can perform using this integration include, but are not limited to:
2626* model pruning
@@ -30,27 +30,29 @@ Some of the tasks you can perform using this integration include, but are not li
3030
3131## Installation
3232To use the script, clone both repositories, install their dependencies,
33- and copy the integrated training script into the yolov5 directory to run from.
33+ and copy the integrated training script into the ` yolov5 ` directory to run from.
3434
3535``` bash
3636# clone
3737git clone https://github.com/ultralytics/yolov5.git
3838git clone https://github.com/neuralmagic/sparseml.git
3939
4040# copy script
41- cp sparseml/integrations/ultralytics/train.py sparseml/integrations/ultralytics/test.py yolov5
4241cd yolov5
42+ git checkout c9bda11 # latest tested integration commit hash
43+ cp ../sparseml/integrations/ultralytics/* .py yolov5
44+ cp ../sparseml/integrations/ultralytics/deepsparse/* .py
4345
4446# install dependencies
4547pip install -r requirements.txt
46- pip install sparseml
48+ pip install sparseml deepsparse
4749```
4850
4951
5052## Script
5153` integrations/ultralytics/train.py ` modifies
5254[ ` train.py ` ] ( https://github.com/ultralytics/yolov5/blob/master/train.py )
53- from yolov5 to include a ` sparseml-recipe ` argument
55+ from ` yolov5 ` to include a ` sparseml-recipe ` argument
5456to run SparseML optimizations with. This can be a file path to a local
5557SparseML recipe or a SparseZoo model stub prefixed by ` zoo: ` such as
5658` zoo:cv/detection/yolo_v3-spp/pytorch/ultralytics/coco/pruned-aggressive ` .
@@ -61,13 +63,13 @@ initial checkpoint, pass that model's SparseZoo stub prefixed by `zoo:` to the
6163` --initial-checkpoint ` argument.
6264
6365Running the script will
64- follow the normal yolov5 training flow with the given SparseML optimizations enabled.
66+ follow the normal ` yolov5 ` training flow with the given SparseML optimizations enabled.
6567
6668Some considerations:
6769
6870* ` --sparseml-recipe ` is a required parameter
6971* ` --epochs ` will now be overridden by the epochs set in the SparseML recipe
70- * if using learning rate schedulers both with the yolov5 script and your recipe, they
72+ * if using learning rate schedulers both with the ` yolov5 ` script and your recipe, they
7173may conflict with each other causing unintended side effects, so choose
7274hyperparameters accordingly
7375* Modifiers will log their outputs to the console as well as to the TensorBoard file
@@ -102,6 +104,39 @@ python train.py \
102104```
103105
104106
105- ## Server
106- The ` server/ ` directory contians an self-documented example of deploying a sparsified
107- Yolo model with the DeepSparse engine.
107+ ## DeepSparse Examples
108+ The [ DeepSparse] ( https://github.com/neuralmagic/deepsparse ) engine can be used for effcient
109+ inference on sparsified YOLOv3 models. The ` deepsparse ` directory contains examples of using
110+ DeepSparse for benchmarking performance and in an inference server environment.
111+
112+ ### Installation
113+ To use these examples after performing the previous installations, copy over the python files
114+ to the ` yolov5 ` directory and install DeepSparse.
115+
116+ ``` bash
117+ # copy DeepSparse python files
118+ cp sparseml/integrations/ultralytics/deepsparse/* .py yolov5
119+ cd yolov5
120+
121+ # install deepsparse and server dependencies
122+ pip install deepsparse flask flask-cors
123+ ```
124+
125+
126+ ### Benchmarking
127+ ` benchmarking.py ` is a script for benchmarking sparsified and quantized YOLOv3
128+ performance with DeepSparse. For a full list of options run ` python benchmarking.py -h ` .
129+
130+ To run a benchmark run:
131+ ``` bash
132+ python benchmark.py
133+ zoo:cv/detection/yolo_v3-spp/pytorch/ultralytics/coco/pruned_quant-aggressive_90 \
134+ --batch-size 32 \
135+ --quantized-inputs
136+ ```
137+
138+ Note for quantized performance, your CPU must support VNNI instructions.
139+
140+ ### Server
141+ ` sparseml/integrations/ultralytics/deepsparse/SERVER.md ` contains relevant
142+ documentation for running the server and client examples.
0 commit comments