Coder Social home page Coder Social logo

mobileone-pytorch's Introduction

MobileOne PyTorch

Unofficial PyTorch implementation of An Improved One millisecond Mobile Backbone paper.

Quickstart

Install with pip install mobileone_pytorch and create a MobileOne with:

from mobileone_pytorch import mobileone_s1
model = mobileone_s1()

Overview

This repository contains an implementation of MobileOne.

Features:

  • Implementation of all MobileOne versions
  • Reparametrization for model deployment

Upcomining features:

  • Squeeze-and-Excitation block for MobileOne S4

Help wanted:

  • Training models on ImageNet

Table of contents

  1. About MobileOne
  2. Installation
  3. Usage

About MobileOne

MobileOne is a novel architecture that with variants achieves an inference time under 1 ms on an iPhone12 with 75.9% top-1 accuracy on ImageNet.

  • MobileOne achieves state-of-the-art performance within the efficient architectures while being many times faster on mobile.

  • The best model (S4) obtains similar performance on ImageNet as Mobile-Former while being 38× faster. Moreover it obtains 2.3% better top-1 accuracy on ImageNet than EfficientNet at similar latency.

Installation

Install via pip:

pip install mobileone_pytorch

Or install from source:

git clone https://github.com/federicopozzi33/MobileOne-PyTorch.git
cd mobileone_pytorch
pip install -e .

Usage

Create models

Create MobileOne models:

from mobileone_pytorch import (
   mobileone_s0, 
   mobileone_s1, 
   mobileone_s2, 
   mobileone_s3, 
   mobileone_s4
)

model_s0 = mobileone_s0()
model_s1 = mobileone_s1()
model_s2 = mobileone_s2()
model_s3 = mobileone_s3()
model_s4 = mobileone_s4()

Deployment

Deploy a MobileOne through reparametrization:

import torch
from mobileone_pytorch import mobileone_s1

x = torch.rand(1, 3, 224, 224)

model = mobileone_s1()
deployed = model.reparametrize()

model.eval()
deployed.eval()

out1 = model(x)
out2 = deployed(x)

torch.testing.assert_close(out1, out2)

Contributing

If you find a bug, create a GitHub issue. Similarly, if you have questions, simply post them as GitHub issues.

mobileone-pytorch's People

Contributors

federicopozzi33 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mobileone-pytorch's Issues

Questions about Multiple Inputs?

How do multiple inputs reparametrize, because the reparametrize function returns nn.Sequential, my multiple inputs are input between different layers, for example two inputs in the first layer and two inputs in the nth layer
The only thing I can think of at present is to build a model after reparametrize according to the trained model, and then read the parameters of the reparametrize model after training.
Is there a better way ?

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.