facebookresearch / esm

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

How do I fix the issue of "TypeError: get_batch_converter() takes 1 positional argument but 2 were given" #303

Closed JiayuanDing100 closed 1 year ago

JiayuanDing100 commented 1 year ago

Hi Team, When i run the command below without any coding change after cloning repo, I got the issue: python scripts/extract.py esm2_t33_650M_UR50D examples/data/some_proteins.fasta \

examples/data/some_proteins_emb_esm2 --repr_layers 0 32 33 --include mean per_tok

Issue: Downloading: "https://dl.fbaipublicfiles.com/fair-esm/regression/esm2_t33_650M_UR50D-contact-regression.pt" to /mnt/home/xxxx/.cache/torch/hub/checkpoints/esm2_t33_650M_UR50D-contact-regression.pt Transferred model to GPU Traceback (most recent call last): File "scripts/extract.py", line 136, in main(args) File "scripts/extract.py", line 77, in main dataset, collate_fn=alphabet.get_batch_converter(args.truncation_seq_length), batch_sampler=batches TypeError: get_batch_converter() takes 1 positional argument but 2 were given

Could you please point it out whether there is anything wrong? Thanks

ZhiYeG commented 1 year ago

Remove the parameter args.truncation_seq_length should yield the results. This is due to the un update file "./env/lib/python3.8/site-packages/esm/data.py: def get_batch_converter(self):" in your pip install esm package.

nikitos9000 commented 1 year ago

Thanks for reporting this! I'll rebuild the package to incorporate all the recent changes shortly.

HelloYiHan commented 1 year ago

I also encounter this problem and hope to be solved soon. Thanks!

tomsercu commented 1 year ago

This is a version mismatch problem and will be fixed if you pip install the same version as you're running: git checkout v1.0.2 or pip install . from repo root.

nikitos9000 commented 1 year ago

@JiayuanDing100 @HelloYiHan Sorry for the delay, please try to upgrade to the latest package version (1.0.3) from pip and check if the issue is still in place?

HelloYiHan commented 1 year ago

It was solved by: pip install git+https://github.com/facebookresearch/esm.git

Thank you for your help!