Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load MobileViT for my project #69

Open
Sehaba95 opened this issue Feb 4, 2023 · 5 comments
Open

How to load MobileViT for my project #69

Sehaba95 opened this issue Feb 4, 2023 · 5 comments

Comments

@Sehaba95
Copy link

Sehaba95 commented Feb 4, 2023

Hi!

I want to use MobileViT and train it using my own dataset (on Google Colab). I couldn't understand how can I use the code in this repository to instantiate just MobileViT model, and use it (I have a very specific data augmentation functions to use).

I am looking for a code to do something like this:

import cvnets.models.classification import MobileViT
import torch

model = MobileViT()
model.load_state_dict(torch.load(PATH))

# Train ...

How can I do that with the original implementation of MobileViT ?

@Amadeus-AI
Copy link

Amadeus-AI commented Mar 1, 2023

Their code of creating model is kind of messy, but I trace their code and found a way to somewhat get rid of it.
First, suggest we have the weight.pt and config.yaml of a model from model_zoo
then we can

import torch
from options.opts import get_training_arguments
from cvnets import get_model

def save_model(*args, **kwargs):
    opts = get_training_arguments()
    model = get_model(opts)
    torch.save(model, 'model_structure.pt')

if __name__ == "__main__":
    save_model()
python .\save_model.py --common.config-file config.yaml

to get the whole specific model structure saved in pt file.

From now on, we can do whatever we want without a lot of unnecessary dependency / information.

import torch

model = torch.load('model_structure.pt')
model.load_state_dict(torch.load('weight.pt'))

# Train ...

Little suggestion to the dev team, some sample code of how to inference your model that list in model_zoo using a single sample picture in 'simple python code' (not some prebuilt executable) will be helpful, like any other modern github model release will do. (https://github.com/openai/CLIP FYI)

@tuobaye11
Copy link

how do i use ml-cvnet?
when i use follow command

export CFG_FILE="config/classification/imagenet/resnet.yaml"
cvnets-train --common.config-file $CFG_FILE --common.results-loc classification_results

main_train: Command not found

@acrlife
Copy link

acrlife commented Oct 26, 2023

how do i use ml-cvnet? when i use follow command

export CFG_FILE="config/classification/imagenet/resnet.yaml" cvnets-train --common.config-file $CFG_FILE --common.results-loc classification_results

main_train: Command not found

I also have this question,are you have a solution?

@LenaDSK
Copy link

LenaDSK commented Mar 18, 2024

Their code of creating model is kind of messy, but I trace their code and found a way to somewhat get rid of it. First, suggest we have the weight.pt and config.yaml of a model from model_zoo then we can

import torch
from options.opts import get_training_arguments
from cvnets import get_model

def save_model(*args, **kwargs):
    opts = get_training_arguments()
    model = get_model(opts)
    torch.save(model, 'model_structure.pt')

if __name__ == "__main__":
    save_model()
python .\save_model.py --common.config-file config.yaml

to get the whole specific model structure saved in pt file.

From now on, we can do whatever we want without a lot of unnecessary dependency / information.

import torch

model = torch.load('model_structure.pt')
model.load_state_dict(torch.load('weight.pt'))

# Train ...

Little suggestion to the dev team, some sample code of how to inference your model that list in model_zoo using a single sample picture in 'simple python code' (not some prebuilt executable) will be helpful, like any other modern github model release will do. (https://github.com/openai/CLIP FYI)

@LenaDSK
Copy link

LenaDSK commented Mar 18, 2024

I want to fine tune the Mobilevit model for my dataset (only classification model needed). So, I need to download the Mobilevit xxs version, with Imagenet pretrained weights. I have implemented the Read me instructions. I have issues downloading the classification Mobilevit model. Could you please guide me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants