webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

【Python】Hugging Face Hub と対話するためのクライアント ライブラリ「huggingface_hub」のインストール

カテゴリ: AI(人工知能)

Hugging Face Hubと対話するためのクライアント ライブラリ「huggingface_hub」のインストールについて解説しています。

Hugging Face Hubは、90,000を超えるモデル、14,000のデータセット、12,000 のデモを備えたプラットフォームで、ユーザーはML(機械学習)ワークフロー(機械学習モデルの開発と展開のプロセス)で簡単に共同作業できる。

「huggingface_hub(https://github.com/huggingface/huggingface_hub)」は、モデル、データセットを簡単にダウンロード、アップロードすることができます。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows11)

■huggingface_hubをインストールする

huggingface_hubをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install huggingface_hub

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install huggingface_hub

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting huggingface_hub

Downloading huggingface_hub-0.14.1-py3-none-any.whl (224 kB)

|████████████████████████████████| 224 kB 1.7 MB/s

Collecting fsspec

Downloading fsspec-2023.5.0-py3-none-any.whl (160 kB)

|████████████████████████████████| 160 kB 2.2 MB/s

Collecting packaging>=20.9

Using cached packaging-23.1-py3-none-any.whl (48 kB)

Collecting requests

Using cached requests-2.31.0-py3-none-any.whl (62 kB)

Collecting filelock

Using cached filelock-3.12.0-py3-none-any.whl (10 kB)

Collecting tqdm>=4.42.1

Using cached tqdm-4.65.0-py3-none-any.whl (77 kB)

Collecting typing-extensions>=3.7.4.3

Downloading typing_extensions-4.6.2-py3-none-any.whl (31 kB)

Collecting pyyaml>=5.1

Using cached PyYAML-6.0-cp38-cp38-win_amd64.whl (155 kB)

Collecting colorama

Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)

Collecting charset-normalizer<4,>=2

Using cached charset_normalizer-3.1.0-cp38-cp38-win_amd64.whl (96 kB)

Collecting urllib3<3,>=1.21.1

Using cached urllib3-2.0.2-py3-none-any.whl (123 kB)

Collecting certifi>=2017.4.17

Using cached certifi-2023.5.7-py3-none-any.whl (156 kB)

Collecting idna<4,>=2.5

Using cached idna-3.4-py3-none-any.whl (61 kB)

Installing collected packages: urllib3, idna, colorama, charset-normalizer, certifi, typing-extensions, tqdm, requests, pyyaml, packaging, fsspec, filelock, huggingface-hub

WARNING: The script normalizer.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script tqdm.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script huggingface-cli.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed certifi-2023.5.7 charset-normalizer-3.1.0 colorama-0.4.6 filelock-3.12.0 fsspec-2023.5.0 huggingface-hub-0.14.1 idna-3.4 packaging-23.1 pyyaml-6.0 requests-2.31.0 tqdm-4.65.0 typing-extensions-4.6.2 urllib3-2.0.2

WARNING: You are using pip version 21.1.1; however, version 23.1.2 is available.

You should consider upgrading via the 'C:\Program Files\Python38\python.exe -m pip install --upgrade pip' command.

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、huggingface_hubが正常にインストールされたことになります。

なお、今回はhuggingface_hubのバージョン0.14.1をインストールしました。