Downloading the model for offline use #133
Unanswered
daniloimparato
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
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 driveThen 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.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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