GithubHelp home page GithubHelp logo

Running inference on mobile about ace HOT 4 OPEN

nianticlabs avatar nianticlabs commented on August 20, 2024
Running inference on mobile

from ace.

Comments (4)

daniel-sudz avatar daniel-sudz commented on August 20, 2024

it looks this issue would be a problem with making the model scriptable: pytorch/pytorch#36061
https://github.com/nianticlabs/ace/blob/main/ace_network.py#L91

one alternative would be to do something like this:

        self.res_blocks = nn.ModuleList(
            nn.ModuleList(([
                nn.Conv2d(self.head_channels, self.head_channels, 1, 1, 0),
                nn.Conv2d(self.head_channels, self.head_channels, 1, 1, 0),
                nn.Conv2d(self.head_channels, self.head_channels, 1, 1, 0),
            ])) for block in range(num_head_blocks)
        )

though this would end up breaking this import:

pattern = re.compile(r"^heads\.\d+c0\.weight$")

from ace.

daniel-sudz avatar daniel-sudz commented on August 20, 2024

@tcavallari I would really love to get inference to run on mobile if it's possible, but it appears as though the pretrained weights must be retrained as per this issue (I'm assuming that there are currently no plans to make the code for the pretrained weights available):

pytorch/pytorch#36061

To make these projects scriptable, we must replace list of modules with nn.ModuleList which will make the pretrained models invalid, since the replacement will change the keys of state_dict, and may increase the number of model parameters.

from ace.

tcavallari avatar tcavallari commented on August 20, 2024

Hello!

To make these projects scriptable, we must replace list of modules with nn.ModuleList which will make the pretrained models invalid, since the replacement will change the keys of state_dict, and may increase the number of model parameters.

I don't think it's necessary to retrain the encoder. You can create a scriptable architecture using nn.ModuleList and inserting the same convolution layers (keeping the same parameters, i.e. kernel size, stride, padding, etc...) inside it. The number of model parameters shouldn't change at all.

Then it should just be a matter of replacing the weights in the new state_dict with the weights in the pretrained one we provide with the repo. You just have to figure out which keys in the new dict map to which keys in the old dictionary, but it should be relatively easy.

from ace.

daniel-sudz avatar daniel-sudz commented on August 20, 2024

Hello!

To make these projects scriptable, we must replace list of modules with nn.ModuleList which will make the pretrained models invalid, since the replacement will change the keys of state_dict, and may increase the number of model parameters.

I don't think it's necessary to retrain the encoder. You can create a scriptable architecture using nn.ModuleList and inserting the same convolution layers (keeping the same parameters, i.e. kernel size, stride, padding, etc...) inside it. The number of model parameters shouldn't change at all.

Then it should just be a matter of replacing the weights in the new state_dict with the weights in the pretrained one we provide with the repo. You just have to figure out which keys in the new dict map to which keys in the old dictionary, but it should be relatively easy.

Ok awesome I think I managed to figure it out. I believe this change should be completely seamless in terms of back-compat so do you think we could merge this into main? I made a PR here in #22. Thank you so much for the guidance

from ace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.