Skip to content

Commit

Permalink
updated Reparameterization weight path & added steps for doing Repara…
Browse files Browse the repository at this point in the history
…meterization ,also fixed few typos (WongKinYiu#552)

* Update reparameterization.ipynb

* Update reparameterization.ipynb

* Update reparameterization.ipynb

* Update reparameterization.ipynb

* Update reparameterization.ipynb

* Add files via upload

* Update userdata.sh

fix typo of yolov7
  • Loading branch information
akashAD98 authored Sep 12, 2022
1 parent 44d8ab4 commit 09d6293
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
38 changes: 31 additions & 7 deletions tools/reparameterization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@
"# Reparameterization"
]
},
{
"cell_type": "markdown",
"id": "9725e211",
"metadata": {},
"source": [
"\n",
"### What is Reparameterization ?\n",
"Reparameterization is used to reduce trainable BoF modules into deploy model for fast inference. For example merge BN to conv, merge YOLOR to conv, ..etc\n",
"However, before reparameterization, the model has more parameters and computation cost.reparameterized model (cfg/deploy) used for deployment purpose\n",
"\n",
"\n",
"\n",
"### Steps required for model conversion.\n",
"1.train custom model & you will get your own weight i.e custom_weight.pt / use (pretrained weight which is available i.e yolov7_traing.pt)\n",
"\n",
"2.Converting this weight using Reparameterization method.\n",
"\n",
"3.Trained model (cfg/training) and reparameterized model (cfg/deploy) will get same prediction results.\n",
"However, before reparameterization, the model has more parameters and computation cost.\n",
"\n",
"4.Convert reparameterized weight into onnx & tensorrt\n",
"For faster inference & deployment purpose."
]
},
{
"cell_type": "markdown",
"id": "13393b70",
Expand All @@ -32,7 +56,7 @@
"\n",
"device = select_device('0', batch_size=1)\n",
"# model trained by cfg/training/*.yaml\n",
"ckpt = torch.load('cfg/training/yolov7.pt', map_location=device)\n",
"ckpt = torch.load('cfg/training/yolov7_training.pt', map_location=device)\n",
"# reparameterized model in cfg/deploy/*.yaml\n",
"model = Model('cfg/deploy/yolov7.yaml', ch=3, nc=80).to(device)\n",
"\n",
Expand Down Expand Up @@ -94,7 +118,7 @@
"\n",
"device = select_device('0', batch_size=1)\n",
"# model trained by cfg/training/*.yaml\n",
"ckpt = torch.load('cfg/training/yolov7x.pt', map_location=device)\n",
"ckpt = torch.load('cfg/training/yolov7x_trainig.pt', map_location=device)\n",
"# reparameterized model in cfg/deploy/*.yaml\n",
"model = Model('cfg/deploy/yolov7x.yaml', ch=3, nc=80).to(device)\n",
"\n",
Expand Down Expand Up @@ -156,7 +180,7 @@
"\n",
"device = select_device('0', batch_size=1)\n",
"# model trained by cfg/training/*.yaml\n",
"ckpt = torch.load('cfg/training/yolov7-w6.pt', map_location=device)\n",
"ckpt = torch.load('cfg/training/yolov7-w6_trainig.pt', map_location=device)\n",
"# reparameterized model in cfg/deploy/*.yaml\n",
"model = Model('cfg/deploy/yolov7-w6.yaml', ch=3, nc=80).to(device)\n",
"\n",
Expand Down Expand Up @@ -328,7 +352,7 @@
"\n",
"device = select_device('0', batch_size=1)\n",
"# model trained by cfg/training/*.yaml\n",
"ckpt = torch.load('cfg/training/yolov7-d6.pt', map_location=device)\n",
"ckpt = torch.load('cfg/training/yolov7-d6_trainig.pt', map_location=device)\n",
"# reparameterized model in cfg/deploy/*.yaml\n",
"model = Model('cfg/deploy/yolov7-d6.yaml', ch=3, nc=80).to(device)\n",
"\n",
Expand Down Expand Up @@ -414,7 +438,7 @@
"\n",
"device = select_device('0', batch_size=1)\n",
"# model trained by cfg/training/*.yaml\n",
"ckpt = torch.load('cfg/training/yolov7-e6e.pt', map_location=device)\n",
"ckpt = torch.load('cfg/training/yolov7-e6e_trainig.pt', map_location=device)\n",
"# reparameterized model in cfg/deploy/*.yaml\n",
"model = Model('cfg/deploy/yolov7-e6e.yaml', ch=3, nc=80).to(device)\n",
"\n",
Expand Down Expand Up @@ -487,7 +511,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.7.0 ('py37')",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -501,7 +525,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.0"
"version": "3.9.7"
},
"vscode": {
"interpreter": {
Expand Down
4 changes: 2 additions & 2 deletions utils/aws/userdata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
cd home/ubuntu
if [ ! -d yolor ]; then
echo "Running first-time script." # install dependencies, download COCO, pull Docker
git clone -b paper https://github.com/WongKinYiu/yolor && sudo chmod -R 777 yolor
cd yolor
git clone -b main https://github.com/WongKinYiu/yolov7 && sudo chmod -R 777 yolov7
cd yolov7
bash data/scripts/get_coco.sh && echo "Data done." &
sudo docker pull nvcr.io/nvidia/pytorch:21.08-py3 && echo "Docker done." &
python -m pip install --upgrade pip && pip install -r requirements.txt && python detect.py && echo "Requirements done." &
Expand Down

0 comments on commit 09d6293

Please sign in to comment.