-
Notifications
You must be signed in to change notification settings - Fork 1.8k
pruning detection models #4477
Comments
Hello @XinMa-AI , we don't have an example for the detection model right now. Which detection model do you want to apply for pruning? or you can contribute one example to NNI if it's convenient for you. |
Hi, J-shang, I would like to prune the 'fasterrcnn_resnet50_fpn' model from torchvision database. I just want to demonstrate whether NNI can prune some detection models. So, could you please tell me whether NNI supports to prune detection models? Thanks~ |
In fact, NNI pruning the module weight, I find that |
Hi, We are currently using NNI to prune YOLOv5 model, but we have encountered such an error. How can we solve this problem? This is the code:
This is the problem we suffered from: In select module!!! |
Hello @XinMa-AI ,
We have tried NNI compression on yolov3, maybe you can try v3 at first, and we will try to fix these bugs you propose. |
Thanks for your reply to my colleague, for the latest version of the yolov5 model, I added some Judgment condition to nni/compression/pytorch/speedup/compressor.py
to skip that branch. However, in the subsequent speedup process, new problems appeared
|
Hi @syswyl ,
I didn't dig into this problem, but I guess it is due to the |
Hi, @J-shang, we use the following codes to check the predecessors and successors of one node, we found the predecessors of tree nodes in
We think the predecessors of the `select` operation may be the model.24.m.2 or the `shape` operation after `Conv`. We are wondering whether those none predecessors cause this problem? And we also directly skip `model.24` by using `cfg_list`, but we found it doesn't work. |
Hello @J-shang @XinMa-AI . I am also pruning the yolov5 model now, and there are several problems. Q1:When I do Q2:when I do
Q3:I also directly skip a block by using
I chose one of these names.Do you have any specific requirements? |
Hi, @sqz-07040120:
|
Thank you for your reply.Wish you a pleasant work
…------------------ 原始邮件 ------------------
发件人: "Xin ***@***.***>;
发送时间: 2022年1月25日(星期二) 晚上7:26
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [microsoft/nni] pruning detection models (Issue #4477)
Hello @J-shang @XinMa-AI .
I am also pruning the yolov5 model now, and there are several problems.
Q1:When I do ModelSpeedup(model, dummy_input=im, masks_file=masks).speedup_model(),the dummy_input() won't match the 'input' of the corresponding layer (to be exact , the silce_block in this picture) in my network, so I changed the *duumy_input to dummy_input[0] to solve this problem.It hasn't gone wrong yet.
Q2:when I do ModelSpeedup(model, dummy_input=im, masks_file=masks).speedup_model(),it will stop with problem
[2022-01-25 18:58:29] INFO (nni.compression.pytorch.speedup.compressor/MainThread) infer module masks... [2022-01-25 18:58:29] INFO (nni.compression.pytorch.speedup.compressor/MainThread) Update mask for backbone.focus.slice_block [2022-01-25 18:58:29] INFO (nni.compression.pytorch.speedup.compressor/MainThread) Update mask for backbone.focus.CSM1.c1 [2022-01-25 18:58:30] INFO (nni.compression.pytorch.speedup.compressor/MainThread) Update mask for backbone.focus.CSM1.aten::sigmoid.70 [2022-01-25 18:58:30] INFO (nni.compression.pytorch.speedup.compressor/MainThread) Update mask for backbone.focus.CSM1.aten::mul.71 Traceback (most recent call last): File "C:\Users\39826\Desktop\caoooooooooooo\nni_prune.py", line 95, in <module> m_speedup.speedup_model() File "C:\Users\39826\AppData\Roaming\Python\Python39\site-packages\nni\compression\pytorch\speedup\compressor.py", line 509, in speedup_model self.infer_modules_masks() File "C:\Users\39826\AppData\Roaming\Python\Python39\site-packages\nni\compression\pytorch\speedup\compressor.py", line 355, in infer_modules_masks self.update_direct_sparsity(curnode) File "C:\Users\39826\AppData\Roaming\Python\Python39\site-packages\nni\compression\pytorch\speedup\compressor.py", line 216, in update_direct_sparsity _auto_infer = AutoMaskInference( File "C:\Users\39826\AppData\Roaming\Python\Python39\site-packages\nni\compression\pytorch\speedup\infer_mask.py", line 85, in __init__ self.output = self.module(dummy_input[0]) TypeError: mul() missing 1 required positional arguments: "other"
I don't know what happened in mul(),the problem has never been solved
Q3:I also directly skip a block by using cfg_list and I found it doesn't work.
[2022-01-25 18:58:28] INFO (FixMaskConflict/MainThread) {'backbone.focus.CSM1.c1': 1, 'backbone.CSM1.c1': 1, 'backbone.CSP1_1.CSM1.c1': 1, 'backbone.CSP1_1.CSM2.c1': 1, 'backbone.CSP1_1.CSM3.c1': 1, 'backbone.CSP1_1.CSM4.c1': 1, 'backbone.CSP1_1.CSM5.c1': 1, 'backbone.CSM2.c1': 1, 'backbone.CSP1_2.CSM1.c1': 1, 'backbone.CSP1_2.CSM2.c1': 1, 'backbone.CSP1_2.CSM3.c1': 1, 'backbone.CSP1_2.CSM4.c1': 1, 'backbone.CSP1_2.CSM5.c1': 1, 'backbone.CSM3.c1': 1, 'backbone.CSP1_3.CSM1.c1': 1, 'backbone.CSP1_3.CSM2.c1': 1, 'backbone.CSP1_3.CSM3.c1': 1, 'backbone.CSP1_3.CSM4.c1': 1, 'backbone.CSP1_3.CSM5.c1': 1, 'backbone.CSM4.c1': 1, 'backbone.SPP.CSM1.c1': 1, 'backbone.SPP.CSM2.c1': 1, 'CSPRes2_body1.CSM1.c1': 1, 'CSPRes2_body1.CSM2.c1': 1, 'CSPRes2_body1.CSM3.c1': 1, 'CSPRes2_body1.CSM4.c1': 1, 'CSPRes2_body1.CSM5.c1': 1, 'CMS1.c1': 1, 'CSPRes2_body2.CSM1.c1': 1, 'CSPRes2_body2.CSM2.c1': 1, 'CSPRes2_body2.CSM3.c1': 1, 'CSPRes2_body2.CSM4.c1': 1, 'CSPRes2_body2.CSM5.c1': 1, 'CMS2.c1': 1, 'CSPRes2_body3.CSM1.c1': 1, 'CSPRes2_body3.CSM2.c1': 1, 'CSPRes2_body3.CSM3.c1': 1, 'CSPRes2_body3.CSM4.c1': 1, 'CSPRes2_body3.CSM5.c1': 1, 'CMS3.c1': 1, 'Conv_Cat1.CSM1.c1': 1, 'CSPRes2_body4.CSM1.c1': 1, 'CSPRes2_body4.CSM2.c1': 1, 'CSPRes2_body4.CSM3.c1': 1, 'CSPRes2_body4.CSM4.c1': 1, 'CSPRes2_body4.CSM5.c1': 1, 'Conv_Cat2.CSM1.c1': 1, 'CSPRes2_body5.CSM1.c1': 1, 'CSPRes2_body5.CSM2.c1': 1, 'CSPRes2_body5.CSM3.c1': 1, 'CSPRes2_body5.CSM4.c1': 1, 'CSPRes2_body5.CSM5.c1': 1, 'conv1': 1, 'conv2': 1, 'conv3': 1}
I chose one of these names.Do you have any specific requirements?
Hi, @sqz-07040120:
The yolov5 model you used seems different from the model we used. We don't find any specific requirement for dummy_input. Any shape of dummy_input is ok.
We suffered from some similar problems with you. But we now don't find any solution for them.
You can see this link (https://nni.readthedocs.io/en/stable/Compression/Tutorial.html?highlight=exclude#specify-the-configuration) to find how to use cofig_list. But we also find it does not work.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Thanks all for the nicely discussion, closing the issue as the issue has been clearly discussed. |
I encounter the similar problems and using config_list to exclude doesn't work as well |
Is there any example for pruning detection models?
The text was updated successfully, but these errors were encountered: