Downloading the model for offline use #133
Unanswered
daniloimparato
asked this question in
Q&A
Replies: 1 comment 1 reply
-
One thing you can do is download model and save it on your server with internet server first... from esm.models.esm3 import ESM3
import torch
client = ESM3.from_pretrained('esm3_sm_open_v1') # download model on local cache
torch.save( client, './esm3_sm_open_v1_full.pth')" # save model onto hard drive Then on your server with no internet connection, do the following: import torch
client = torch.load('./esm3_sm_open_v1_full.pth') # load model from hard drive
#######
# TEST #
#######
from esm.models.esm3 import ESM3
from esm.sdk.api import ESMProtein, SamplingConfig
from esm.utils.constants.models import ESM3_OPEN_SMALL
# Peptidase S1A, chymotrypsin family: https://www.ebi.ac.uk/interpro/structure/PDB/1utn/
protein = ESMProtein(
sequence=(
"FIFLALLGAAVAFPVDDDDKIVGGYTCGANTVPYQVSLNSGYHFCGGSLINSQWVVSAAHCYKSGIQVRLGEDNINVVEG"
"NEQFISASKSIVHPSYNSNTLNNDIMLIKLKSAASLNSRVASISLPTSCASAGTQCLISGWGNTKSSGTSYPDVLKCLKAP"
"ILSDSSCKSAYPGQITSNMFCAGYLEGGKDSCQGDSGGPVVCSGKLQGIVSWGSGCAQKNKPGVYTKVCNYVSWIKQTIASN"
)
)
protein_tensor = client.encode(protein)
output = client.forward_and_sample(
protein_tensor, SamplingConfig(return_per_residue_embeddings=True)
)
print(output.per_residue_embedding.shape) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, everyone.
This is my first time with ESM/Huggingface models in general. I want to load ESM3 on a local server with no internet access. I have tried some general model loading/saving instructions, but no luck so far [1, 2, 3]. I have even tried copying my local cache to the server (
~/.cache/huggingface/hub/models--EvolutionaryScale--esm3-sm-open-v1/
). It seems ESM3 works a bit... differently? Would appreciate some guidance.In other words, how can I change this line from the README to work with a local dir?
I will keep banging my head at the keyboard, but figured it wouldn't hurt asking this question here as well.
Beta Was this translation helpful? Give feedback.
All reactions