question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BLOCKED] Replace IntermediateLayerGetter with feature_extraction.create_feature_extractor()

See original GitHub issue

🚀 The feature

A new feature extraction utility based on FX was introduced by #4302. It allows us to extract internal outputs of a module in a simpler way and it should be a drop-in replacement of the old IntermediateLayerGetter class.

Unfortunately the create_feature_extractor() util is not currently used anywhere on vision. We should investigate using it to replace some of the old approaches. Here is a list of candidates:

  • Replace IntermediateLayerGetter calls in Segmentation models [1, 2]
  • Replace IntermediateLayerGetter calls in Detection models [3]
  • Rewrite model surgery from the SSDFeatureExtractorVGG [4] and SSDLiteFeatureExtractorMobileNet modules [5].

Extra care needs to be given to ensure that the old weights of pre-trained models can still load and the validation statistics remain the same.

Motivation, pitch

Using the latest FX-based utility will help us future proof our code-base.

cc @datumbox

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
datumboxcommented, Dec 15, 2021

Backbones that have been passed through FX won’t have class information in the submodules (see https://github.com/pytorch/pytorch/issues/66335). As a result we might no longer be able to do isinstance() to check for specific blocks. This idiom is often used in detection and segmentation for the weight initialization. So prior replacing the feature extractors we must check that none of the models are affected.

@vfdev-5 I know that you previously replaced segmentation but back then this limitation was not known and it’s not clear if we are affected. I was hoping to take more time prior the next release to check carefully that we didn’t mess up anything before rolling out the change to more places. But if you feel you have the capacity to thoroughly check that none of the models for segmentation or detection are affected, feel free to do it now.

1reaction
vfdev-5commented, Dec 15, 2021

@kingjuno you can draft a PR for 2nd task (“Replace IntermediateLayerGetter calls in Detection models [3]”) and I can review and help with meanwhile.

Read more comments on GitHub >

github_iconTop Results From Across the Web

create_feature_extractor | The Search Engine You Control
Creates a new graph module that returns intermediate nodes from a given model as dictionary with user specified keys as strings, and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found