Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

can not work for object detection model #247

Closed
Jakel21 opened this issue May 9, 2019 · 16 comments
Closed

can not work for object detection model #247

Jakel21 opened this issue May 9, 2019 · 16 comments
Assignees
Labels
object detection pruning This issue is related to pruning question Further information is requested

Comments

@Jakel21
Copy link

Jakel21 commented May 9, 2019

I tried to use distiller for my cascade rcnn model but it did not work for me and i need some help.

I used AGP pruning method and followed the schedule introduced in the guide doc to change my training code, and the backbone resnet50(used in senet model) parameters were selected to prune. However in the process the total sparsity just was 0. It failed. What is the problem and how should i adjust??

in epoch loop:
 e
in train function:
t
when i want to see the mask info, i get this error:
err
i don't know why the mask is not working and i think the masks are set when epoch begin.
ps: i just can't see any model compression project support object detection, including distiller and pocketflow? Why? What is the difference between object detection problems and classification model when we try to compress them ??

looking forward to you answer~3q

@nzmora
Copy link
Contributor

nzmora commented May 9, 2019

Hi @Jakel21,

From the error you get on line 400, it is evident that self.compression_scheduler" is None. This is the AttributeError``` that you receive.
Did you instantiate the scheduler and give it the pruning schedule? -- I don't see it in the code that you pasted.

Regarding your question about support for pruning object-detectors: traditionally most of the research (but not all) about model compression has (and is) performed on image classifiers. It's mostly a matter of convenience I think. There's no particular reason Distiller doesn't support compression of object detectors except for priorities. As far as I know, some people using Distiller have used it to compress object-detection models, but I can't be sure. We'd love it if someone from the community contributed an example.

Cheers,
Neta

@nzmora nzmora added pruning This issue is related to pruning question Further information is requested object detection labels May 9, 2019
@Jakel21
Copy link
Author

Jakel21 commented May 10, 2019

Hi @Jakel21,

From the error you get on line 400, it is evident that self.compression_scheduler" is None. This is the AttributeError``` that you receive.
Did you instantiate the scheduler and give it the pruning schedule? -- I don't see it in the code that you pasted.

Regarding your question about support for pruning object-detectors: traditionally most of the research (but not all) about model compression has (and is) performed on image classifiers. It's mostly a matter of convenience I think. There's no particular reason Distiller doesn't support compression of object detectors except for priorities. As far as I know, some people using Distiller have used it to compress object-detection models, but I can't be sure. We'd love it if someone from the community contributed an example.

Cheers,
Neta

Thanks for the reply~
my compress scheduler looks like this:

version: 1

pruners:
fc_pruner:
class: AutomatedGradualPruner
initial_sparsity: 0.0
final_sparsity: 0.75
weights: [
module.backbone.model.layer1.0.se_module.fc1.weight,
module.backbone.model.layer1.0.se_module.fc2.weight,
module.backbone.model.layer1.1.se_module.fc1.weight,
module.backbone.model.layer1.1.se_module.fc2.weight,
module.backbone.model.layer1.2.se_module.fc1.weight,
module.backbone.model.layer1.2.se_module.fc2.weight,
module.backbone.model.layer2.0.se_module.fc1.weight,
module.backbone.model.layer2.0.se_module.fc2.weight,
module.backbone.model.layer2.1.se_module.fc1.weight,
module.backbone.model.layer2.1.se_module.fc2.weight,
module.backbone.model.layer2.2.se_module.fc1.weight,
module.backbone.model.layer2.2.se_module.fc2.weight,
module.backbone.model.layer2.3.se_module.fc1.weight,
module.backbone.model.layer2.3.se_module.fc2.weight,
module.backbone.model.layer3.0.se_module.fc1.weight,
module.backbone.model.layer3.0.se_module.fc2.weight,
module.backbone.model.layer3.1.se_module.fc1.weight,
module.backbone.model.layer3.1.se_module.fc2.weight,
module.backbone.model.layer3.2.se_module.fc1.weight,
module.backbone.model.layer3.2.se_module.fc2.weight,
module.backbone.model.layer3.3.se_module.fc1.weight,
module.backbone.model.layer3.3.se_moduel.fc2.weight,
module.backbone.model.layer3.4.se_module.fc1.weight,
module.backbone.model.layer3.4.se_module.fc2.weight,
module.backbone.model.layer3.5.se_module.fc1.weight,
module.backbone.model.layer3.5.se_module.fc2.weight,
module.backbone.model.layer4.0.se_module.fc1.weight,
module.backbone.model.layer4.0.se_module.fc2.weight,
module.backbone.model.layer4.1.se_module.fc1.weight,
module.backbone.model.layer4.1.se_module.fc2,weight,
module.backbone.model.layer4.2.se_module.fc1.weight,
module.backbone.model.layer4.2.se_module.fc2.weight]

conv_pruner:
class: AutomatedGradualPruner
initial_sparsity: 0.0
final_sparsity: 0.75
weights: [
module.backbone.model.layer0.conv1.weight,
module.backbone.model.layer1.0.conv1.weight,
module.backbone.model.layer1.0.conv2.weight,
module.backbone.model.layer1.0.conv3.weight,
module.backbone.model.layer1.0.downsample.0.weight,
module.backbone.model.layer1.1.conv1.weight,
module.backbone.model.layer1.1.conv2.weight,
module.backbone.model.layer1.1.conv3.weight,
module.backbone.model.layer1.2.conv1.weight,
module.backbone.model.layer1.2.conv2.weight,
module.backbone.model.layer1.2.conv3.weight,
module.backbone.model.layer2.0.conv1.weight,
module.backbone.model.layer2.0.conv2.weight,
module.backbone.model.layer2.0.conv3.weight,
module.backbone.model.layer2.0.downsample.0.weight,
module.backbone.model.layer2.1.conv1.weight,
module.backbone.model.layer2.1.conv2.weight,
module.backbone.model.layer2.1.conv3.weight,
module.backbone.model.layer2.2.conv1.weight,
module.backbone.model.layer2.2.conv2.weight,
module.backbone.model.layer2.2.conv3.weight,
module.backbone.model.layer2.3.conv1.weight,
module.backbone.model.layer2.3.conv2.weight,
module.backbone.model.layer2.3.conv3.weight,
module.backbone.model.layer3.0.conv1.weight,
module.backbone.model.layer3.0.conv2.weight,
module.backbone.model.layer3.0.downsample.0.weight,
module.backbone.model.layer3.1.conv1.weight,
module.backbone.model.layer3.1.conv2.weight,
module.backbone.model.layer3.1.conv3.weight,
module.backbone.model.layer3.2.conv1.weight,
module.backbone.model.layer3.2.conv2.weight,
module.backbone.model.layer3.2.conv3.weight,
module.backbone.model.layer3.3.conv1.weight,
module.backbone.model.layer3.3.conv2.weight,
module.backbone.model.layer3.3.conv3.weight,
module.backbone.model.layer3.4.conv1.weight,
module.backbone.model.layer3.4.conv2.weight,
module.backbone.model.layer3.4.conv3.weight,
module.backbone.model.layer3.5.conv1.weight,
module.backbone.model.layer3.5.conv2.weight,
module.backbone.model.layer3.5.conv3.weight,
module.backbone.model.layer4.0.conv1.weight,
module.backbone.model.layer4.0.conv2.weight,
module.backbone.model.layer4.0.conv3.weight,
module.backbone.model.layer4.0.downsample.0.weight,
module.backbone.model.layer4.1.conv1.weight,
module.backbone.model.layer4.1.conv2.weight,
module.backbone.model.layer4.1.conv3.weight,
module.backbone.model.layer4.2.conv1.weight,
module.backbone.model.layer4.2.conv2.weight,
module.backbone.model.layer4.2.conv3.weight]

policies:

  • pruner:
    instance_name: conv_pruner
    starting_epoch: 0
    ending_epoch: 50
    frequency: 1

  • pruner:
    instance_name: fc_pruner
    starting_epoch: 0
    ending_epoch: 50
    frequency: 1


and i config the scheduler at the first part of my code:
sc
is there any problem in my config scheduler file or my process of the config? i just follow the introduction guide of the word language model in examples.

@nzmora
Copy link
Contributor

nzmora commented May 10, 2019

Hi @Jakel21,

The schedule and the instantiation of self.compression_scheduler look good. However, from the error you sent:

https://user-images.githubusercontent.com/20606275/57422731-c67d8180-7243-11e9-8938-7ed3a27291c5.png

It is evident that self.compression_scheduler is None. If this is not clear to you, here is the simplest way to reproduce the error message:

>>> a = None
>>> a.zeros_mask_dict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'zeros_mask_dict'

I haven't used mmdetection and I don't know how you integrated Distiller, so without seeing the entire code, I don't think I can help further.
Cheers,
Neta

@Jakel21
Copy link
Author

Jakel21 commented May 10, 2019

Hi @Jakel21,

The schedule and the instantiation of self.compression_scheduler look good. However, from the error you sent:

https://user-images.githubusercontent.com/20606275/57422731-c67d8180-7243-11e9-8938-7ed3a27291c5.png

It is evident that self.compression_scheduler is None. If this is not clear to you, here is the simplest way to reproduce the error message:

>>> a = None
>>> a.zeros_mask_dict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'zeros_mask_dict'

I haven't used mmdetection and I don't know how you integrated Distiller, so without seeing the entire code, I don't think I can help further.
Cheers,
Neta

i will work on it and try to make it work. Thanks for the help anyway.

@saranshkarira
Copy link

saranshkarira commented Jun 19, 2019

try this:
if compression_scheduler is None:

       compression_scheduler = distiller.CompressionScheduler(model)`

@nzmora
Copy link
Contributor

nzmora commented Jun 19, 2019

BTW, @levzlotnik is adding an example for pruning object detectors. This will be shared on github in a couple of weeks I hope.
Cheers,
Neta

@saranshkarira
Copy link

I'm working on them as well, lemme know if need any assistance! @levzlotnik

@RizhaoCai
Copy link

Hi @Jakel21,
The schedule and the instantiation of self.compression_scheduler look good. However, from the error you sent:
https://user-images.githubusercontent.com/20606275/57422731-c67d8180-7243-11e9-8938-7ed3a27291c5.png
It is evident that self.compression_scheduler is None. If this is not clear to you, here is the simplest way to reproduce the error message:

>>> a = None
>>> a.zeros_mask_dict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'zeros_mask_dict'

I haven't used mmdetection and I don't know how you integrated Distiller, so without seeing the entire code, I don't think I can help further.
Cheers,
Neta

i will work on it and try to make it work. Thanks for the help anyway.

Hey dude. Have you solved this problem?

@levzlotnik
Copy link
Contributor

Hey guys, I am working on the torchvision object detection sample at the moment, hopefully will push it soon.

@RizhaoCai
Copy link

RizhaoCai commented Nov 29, 2019

Hey guys, I am working on the torchvision object detection sample at the moment, hopefully will push it soon.

Hello, how is it now? May I also contribute some detection samples?

@bupt-renpei
Copy link

@RizhaoCai Hello, Rizhao, can you pls share your development expreience?

@bupt-renpei
Copy link

@levzlotnik Hi dude, have you finish the object detection compression samples? Thanks for your efforts!

@RizhaoCai
Copy link

@RizhaoCai Hello, Rizhao, can you pls share your development expreience?

The object detection example has been updated
https://github.com/NervanaSystems/distiller/tree/master/examples/object_detection_compression

@bupt-renpei
Copy link

bupt-renpei commented Jan 29, 2020 via email

@RizhaoCai
Copy link

@RizhaoCai Hi Rizhao, Thanks for your help. But I cannot see any change in examples/object_detection_compression, can you give some hints?

What do you can't see any change?
Can you open the link "https://github.com/NervanaSystems/distiller/tree/master/examples/object_detection_compression"?

My experience is quite straightforward.
I just ran the example 'compress_detector.py' given by the link.
And I wrote my version compress_detector.py and put my model (RFB-Net), train_fn, evaluate_fn, data_loader to the code. That is it.

@levzlotnik
Copy link
Contributor

Hi,
Closing this issue since the object detection example has been added several months ago, so please refer to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
object detection pruning This issue is related to pruning question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants