MahmoudAshraf97 / whisper-diarization

Automatic Speech Recognition with Speaker Diarization based on OpenAI Whisper
BSD 2-Clause "Simplified" License
3.28k stars 272 forks source link

Cannot import name 'ModelFilter' from 'huggingface_hub' #202

Closed thibaudbrg closed 1 month ago

thibaudbrg commented 1 month ago

Thank you for your work! I get this error right now: Using Python 3.10.12 or 3.11.0 I get this error. Here is the trace. It is likely coming from nemo from NVIDIA. Need probably a more recent version. Using nemo_toolkit==1.20.0 and tried also with nemo_toolkit==1.21.0

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[16], line 8
      6 import torch
      7 import torchaudio
----> 8 from nemo.collections.asr.models.msdd_models import NeuralDiarizer
      9 from deepmultilingualpunctuation import PunctuationModel
     10 import re

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/collections/asr/__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from nemo.collections.asr import data, losses, models, modules
     16 from nemo.package_info import __version__
     18 # Set collection version equal to NeMo version.

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/collections/asr/losses/__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 15 from nemo.collections.asr.losses.angularloss import AngularSoftmaxLoss
     16 from nemo.collections.asr.losses.audio_losses import MSELoss, SDRLoss
     17 from nemo.collections.asr.losses.ctc import CTCLoss

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/collections/asr/losses/angularloss.py:18
      1 # ! /usr/bin/python
      2 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      3 #
   (...)
     13 # See the License for the specific language governing permissions and
     14 # limitations under the License.
     16 import torch
---> 18 from nemo.core.classes import Loss, Typing, typecheck
     19 from nemo.core.neural_types import LabelsType, LogitsType, LossType, NeuralType
     21 __all__ = ['AngularSoftmaxLoss']

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/core/__init__.py:16
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     15 import nemo.core.neural_types
---> 16 from nemo.core.classes import *

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/core/classes/__init__.py:20
     17 import omegaconf
     18 import pytorch_lightning
---> 20 from nemo.core.classes.common import (
     21     FileIO,
     22     Model,
     23     PretrainedModelInfo,
     24     Serialization,
     25     Typing,
     26     is_typecheck_enabled,
     27     typecheck,
     28 )
     29 from nemo.core.classes.dataset import Dataset, IterableDataset
     30 from nemo.core.classes.exportable import Exportable, ExportFormat

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/core/classes/common.py:40
     37 from omegaconf import DictConfig, OmegaConf
     39 import nemo
---> 40 from nemo.core.classes.mixins.hf_io_mixin import HuggingFaceFileIO
     41 from nemo.core.config.templates.model_card import NEMO_DEFAULT_MODEL_CARD_TEMPLATE
     42 from nemo.core.connectors.save_restore_connector import SaveRestoreConnector

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/core/classes/mixins/__init__.py:28
     16 from nemo.core.classes.mixins.adapter_mixin_strategies import (
     17     ResidualAddAdapterStrategy,
     18     ResidualAddAdapterStrategyConfig,
     19     ReturnResultAdapterStrategy,
     20     ReturnResultAdapterStrategyConfig,
     21 )
     22 from nemo.core.classes.mixins.adapter_mixins import (
     23     AdapterModelPTMixin,
     24     AdapterModuleMixin,
     25     get_registered_adapter,
     26     register_adapter,
     27 )
---> 28 from nemo.core.classes.mixins.hf_io_mixin import HuggingFaceFileIO

File ~/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/nemo/core/classes/mixins/hf_io_mixin.py:19
     16 from pathlib import Path
     17 from typing import Dict, Iterable, List, Optional, Union
---> 19 from huggingface_hub import HfApi, ModelCard, ModelCardData, ModelFilter
     20 from huggingface_hub import get_token as get_hf_token
     21 from huggingface_hub.hf_api import ModelInfo

ImportError: cannot import name 'ModelFilter' from 'huggingface_hub' (/<mypath>/SpeechToText/whisper-diarization/venv/lib/python3.11/site-packages/huggingface_hub/__init__.py)
tbazooka commented 1 month ago

Had the same issue; what worked for me:

pip uninstall huggingface_hub
pip install huggingface-hub==0.20.3
thibaudbrg commented 1 month ago

Yep that worked, Thank you :)

kirahman2 commented 3 weeks ago

I'm using ubuntu 22.04 from the microsoft store on Windows 11. Here is the bash script that I put together. This got everything working seamlessly as of August 2024.

#!/bin/bash

# Create a new conda environment
conda create -n whisper_diar2 python=3.10 --yes

# Initialize conda and activate the new environment
source ~/miniconda3/etc/profile.d/conda.sh
conda activate whisper_diar2

# Upgrade pip
pip install --upgrade pip

# Install JupyterLab and IPython kernel
conda install -c conda-forge jupyterlab --yes
conda install ipykernel --yes
python -m ipykernel install --user --name whisper_diar2 --display-name "whisper_diar2"

# Reinstall PyTorch with CUDA support
#pip uninstall torch --yes
#conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia --yes

# Install Cython and FFmpeg
#pip install cython
sudo apt update && sudo apt install -y cython3 ffmpeg

# https://github.com/MahmoudAshraf97/whisper-diarization/issues/188#issuecomment-2277862623
pip install --upgrade Cython setuptools wheel

# Install other required Python packages
pip install -r requirements.txt

# Install Nemo toolkit (you can modify the version if needed)
pip install nemo_toolkit==1.18.1

# notebook pip installs
pip install git+https://github.com/m-bain/whisperX.git@78dcfaab51005aa703ee21375f81ed31bc248560
pip install --no-build-isolation nemo_toolkit[asr]==1.23.0
pip install --no-deps git+https://github.com/facebookresearch/demucs#egg=demucs
pip install git+https://github.com/oliverguhr/deepmultilingualpunctuation.git
pip install git+https://github.com/MahmoudAshraf97/ctc-forced-aligner.git

# https://github.com/MahmoudAshraf97/whisper-diarization/issues/202
pip uninstall huggingface_hub --yes
pip install huggingface-hub==0.20.3

echo "Installation complete. The environment 'whisper_diar2' is set up and ready to use."
xpfo-go commented 3 weeks ago

Had the same issue; what worked for me:

pip uninstall huggingface_hub
pip install huggingface-hub==0.20.3

thanks bro

phicha20224 commented 2 weeks ago

Installing collected packages: huggingface-hub ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. transformers 4.44.0 requires huggingface-hub<1.0,>=0.23.2, but you have huggingface-hub 0.20.3 which is incompatible.

yuanzhiyong1999 commented 5 days ago

Installing collected packages: huggingface-hub ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. transformers 4.44.0 requires huggingface-hub<1.0,>=0.23.2, but you have huggingface-hub 0.20.3 which is incompatible.

can you solved it?