facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.43k stars 6.4k forks source link

ImportError: cannot import name 'load_model_ensemble_and_task_from_hf_hub' from 'fairseq.checkpoint_utils' #4265

Open loretoparisi opened 2 years ago

loretoparisi commented 2 years ago

To reproduce this issue, try in Colab:

!python -m pip install git+https://github.com/pytorch/fairseq.git

from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
import IPython.display as ipd

models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
    "facebook/fastspeech2-en-200_speaker-cv4",
    arg_overrides={"vocoder": "hifigan", "fp16": False}
)
model = models[0]
TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
generator = task.build_generator(model, cfg)

text = "Hello, this is a test run."

sample = TTSHubInterface.get_model_input(task, text)
wav, rate = TTSHubInterface.get_prediction(task, model, generator, sample)

ipd.Audio(wav, rate=rate)

Stack trace:

ImportError                               Traceback (most recent call last)
[<ipython-input-4-20e4e7332d88>](https://localhost:8080/#) in <module>()
----> 1 from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
      2 from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
      3 import IPython.display as ipd
      4 
      5 

ImportError: cannot import name 'load_model_ensemble_and_task_from_hf_hub' from 'fairseq.checkpoint_utils' (/usr/local/lib/python3.7/dist-packages/fairseq/checkpoint_utils.py)
danjenson commented 2 years ago

seeing this too

Jackylee2032 commented 1 year ago

damn same problem,anyone solved?