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

Encoder weights from local directory #1102

Open
Foundsheep opened this issue Mar 25, 2025 · 3 comments
Open

Encoder weights from local directory #1102

Foundsheep opened this issue Mar 25, 2025 · 3 comments

Comments

@Foundsheep
Copy link

Foundsheep commented Mar 25, 2025

Hi,

It might have been dealt with somewhere, but I couldn't find any post about it.
Bascially, I'm trying to create a model instance without depending on the external network, which means when I instantiate a pre-trained model, it seems like downloading weights from somewhere else.

Can I have its weights in my local machine and instantiate using it?
By the way, I'm using SegFormer just to make things clear

@qubvel
Copy link
Collaborator

qubvel commented Mar 25, 2025

Hi @Foundsheep, to prevent loading weights from remove you can specify encoder_weights=None. Then you can load from a local directory with the standard torch approach as torch.load and model.load_state_dict

@Foundsheep
Copy link
Author

Hi @qubvel,

Thanks for the quick reply.
Then where could I find the model's weights file? If it's somewhere in the documentation, sorry about bothering I couldn't find it.

@qubvel
Copy link
Collaborator

qubvel commented Mar 26, 2025

You can download it while you have an internet into the model, then save with torch.save + model.encoder.state_dict()

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

2 participants