facebookresearch / esm

Evolutionary Scale Modeling (esm): Pretrained language models for proteins
MIT License
2.97k stars 586 forks source link

"model_name" is not defined - ESM-2 #638

Closed bdabykov closed 7 months ago

bdabykov commented 7 months ago

Bug description I am trying to load the pre-trained model ESM-2 esm2_t30_150M_UR50D, I have downloaded the weigths from the official repository and even cloned the repository, but once I run the following code:

import torch
import esm
esmmodel_path = "/home/esm/esm2_t30_150M_UR50D.pt"
model, alphabet = esm.pretrained.load_model_and_alphabet(esmmodel_path)
print("Model loaded")

I got the error:

Traceback (most recent call last):
  File "/home/padding_esm.py", line 36, in <module>
    model, alphabet = esm.pretrained.load_model_and_alphabet(esmmodel_path)
  File "/home/user/miniconda3/envs/phd/lib/python3.9/site-packages/esm/pretrained.py", line 21, in load_model_and_alphabet
    return load_model_and_alphabet_local(model_name)
  File "/home/user/miniconda3/envs/phd/lib/python3.9/site-packages/esm/pretrained.py", line 57, in load_model_and_alphabet_local
    if _has_regression_weights(model_name):
NameError: name 'model_name' is not defined

Additional context I am running this in a conda environment, using python version 3.9.18 and torch 2.1.1

bdabykov commented 7 months ago

Bug description I am trying to load the pre-trained model ESM-2 esm2_t30_150M_UR50D, I have downloaded the weigths from the official repository and even cloned the repository, but once I run the following code:

import torch
import esm
esmmodel_path = "/home/esm/esm2_t30_150M_UR50D.pt"
model, alphabet = esm.pretrained.load_model_and_alphabet(esmmodel_path)
print("Model loaded")

I got the error:

Traceback (most recent call last):
  File "/home/padding_esm.py", line 36, in <module>
    model, alphabet = esm.pretrained.load_model_and_alphabet(esmmodel_path)
  File "/home/user/miniconda3/envs/phd/lib/python3.9/site-packages/esm/pretrained.py", line 21, in load_model_and_alphabet
    return load_model_and_alphabet_local(model_name)
  File "/home/user/miniconda3/envs/phd/lib/python3.9/site-packages/esm/pretrained.py", line 57, in load_model_and_alphabet_local
    if _has_regression_weights(model_name):
NameError: name 'model_name' is not defined

Additional context I am running this in a conda environment, using python version 3.9.18 and torch 2.1.1

I have solved this issue creating a new conda environment and downgrading the Pytorch version to pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0