Skip to content

Commit 09d6293

Browse files
authored
updated Reparameterization weight path & added steps for doing Reparameterization ,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
1 parent 44d8ab4 commit 09d6293

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

tools/reparameterization.ipynb

+31-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@
88
"# Reparameterization"
99
]
1010
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "9725e211",
14+
"metadata": {},
15+
"source": [
16+
"\n",
17+
"### What is Reparameterization ?\n",
18+
"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",
19+
"However, before reparameterization, the model has more parameters and computation cost.reparameterized model (cfg/deploy) used for deployment purpose\n",
20+
"\n",
21+
"\n",
22+
"\n",
23+
"### Steps required for model conversion.\n",
24+
"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",
25+
"\n",
26+
"2.Converting this weight using Reparameterization method.\n",
27+
"\n",
28+
"3.Trained model (cfg/training) and reparameterized model (cfg/deploy) will get same prediction results.\n",
29+
"However, before reparameterization, the model has more parameters and computation cost.\n",
30+
"\n",
31+
"4.Convert reparameterized weight into onnx & tensorrt\n",
32+
"For faster inference & deployment purpose."
33+
]
34+
},
1135
{
1236
"cell_type": "markdown",
1337
"id": "13393b70",
@@ -32,7 +56,7 @@
3256
"\n",
3357
"device = select_device('0', batch_size=1)\n",
3458
"# model trained by cfg/training/*.yaml\n",
35-
"ckpt = torch.load('cfg/training/yolov7.pt', map_location=device)\n",
59+
"ckpt = torch.load('cfg/training/yolov7_training.pt', map_location=device)\n",
3660
"# reparameterized model in cfg/deploy/*.yaml\n",
3761
"model = Model('cfg/deploy/yolov7.yaml', ch=3, nc=80).to(device)\n",
3862
"\n",
@@ -94,7 +118,7 @@
94118
"\n",
95119
"device = select_device('0', batch_size=1)\n",
96120
"# model trained by cfg/training/*.yaml\n",
97-
"ckpt = torch.load('cfg/training/yolov7x.pt', map_location=device)\n",
121+
"ckpt = torch.load('cfg/training/yolov7x_trainig.pt', map_location=device)\n",
98122
"# reparameterized model in cfg/deploy/*.yaml\n",
99123
"model = Model('cfg/deploy/yolov7x.yaml', ch=3, nc=80).to(device)\n",
100124
"\n",
@@ -156,7 +180,7 @@
156180
"\n",
157181
"device = select_device('0', batch_size=1)\n",
158182
"# model trained by cfg/training/*.yaml\n",
159-
"ckpt = torch.load('cfg/training/yolov7-w6.pt', map_location=device)\n",
183+
"ckpt = torch.load('cfg/training/yolov7-w6_trainig.pt', map_location=device)\n",
160184
"# reparameterized model in cfg/deploy/*.yaml\n",
161185
"model = Model('cfg/deploy/yolov7-w6.yaml', ch=3, nc=80).to(device)\n",
162186
"\n",
@@ -328,7 +352,7 @@
328352
"\n",
329353
"device = select_device('0', batch_size=1)\n",
330354
"# model trained by cfg/training/*.yaml\n",
331-
"ckpt = torch.load('cfg/training/yolov7-d6.pt', map_location=device)\n",
355+
"ckpt = torch.load('cfg/training/yolov7-d6_trainig.pt', map_location=device)\n",
332356
"# reparameterized model in cfg/deploy/*.yaml\n",
333357
"model = Model('cfg/deploy/yolov7-d6.yaml', ch=3, nc=80).to(device)\n",
334358
"\n",
@@ -414,7 +438,7 @@
414438
"\n",
415439
"device = select_device('0', batch_size=1)\n",
416440
"# model trained by cfg/training/*.yaml\n",
417-
"ckpt = torch.load('cfg/training/yolov7-e6e.pt', map_location=device)\n",
441+
"ckpt = torch.load('cfg/training/yolov7-e6e_trainig.pt', map_location=device)\n",
418442
"# reparameterized model in cfg/deploy/*.yaml\n",
419443
"model = Model('cfg/deploy/yolov7-e6e.yaml', ch=3, nc=80).to(device)\n",
420444
"\n",
@@ -487,7 +511,7 @@
487511
],
488512
"metadata": {
489513
"kernelspec": {
490-
"display_name": "Python 3.7.0 ('py37')",
514+
"display_name": "Python 3 (ipykernel)",
491515
"language": "python",
492516
"name": "python3"
493517
},
@@ -501,7 +525,7 @@
501525
"name": "python",
502526
"nbconvert_exporter": "python",
503527
"pygments_lexer": "ipython3",
504-
"version": "3.7.0"
528+
"version": "3.9.7"
505529
},
506530
"vscode": {
507531
"interpreter": {

utils/aws/userdata.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
cd home/ubuntu
88
if [ ! -d yolor ]; then
99
echo "Running first-time script." # install dependencies, download COCO, pull Docker
10-
git clone -b paper https://github.com/WongKinYiu/yolor && sudo chmod -R 777 yolor
11-
cd yolor
10+
git clone -b main https://github.com/WongKinYiu/yolov7 && sudo chmod -R 777 yolov7
11+
cd yolov7
1212
bash data/scripts/get_coco.sh && echo "Data done." &
1313
sudo docker pull nvcr.io/nvidia/pytorch:21.08-py3 && echo "Docker done." &
1414
python -m pip install --upgrade pip && pip install -r requirements.txt && python detect.py && echo "Requirements done." &

0 commit comments

Comments
 (0)