2024年1月3日 星期三

Colab : The secret HF_TOKEN does not exist in your Colab secrets

2024年1月3日 星期三

 有人留言反應「雄 : 以 Faster Whisper 將影音辨識為文字檔案(字幕或逐字稿)」的 Colab 筆記本執行完有錯誤訊息,前幾週還有用過,試了一下,會出現類似這樣的訊息:

/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:72: UserWarning:
The secret `HF_TOKEN` does not exist in your Colab secrets.
To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.
You will be able to reuse this secret in all of your notebooks.
Please note that authentication is recommended but still optional to access public models or datasets.
warnings.warn(

追了一下 Faster Whisper 的原始碼,應該卡在「faster_whisper /utils.py」中的「download_model」,用來下載語音辨識模型資料的程序。它使用了「huggingface_hub」來下載相關檔案,而 huggingface_hub 兩週前的 v0.20.0 起,支援讀取 Colab 的 Secret 中設定的 HF_TOKEN 參數內容:

Authentication has been greatly improved in Google Colab. The best way to authenticate in a Colab notebook is to define a HF_TOKEN secret in your personal secrets. When a notebook tries to reach the Hub, a pop-up will ask you if you want to share the HF_TOKEN secret with this notebook -as an opt-in mechanism. 

也不知道哪裡出了問題,它說不認證也可以讀到 HugginFace Hub 專案中的檔案,卻卡住了。

試了半天,沒辦法解決 Colab 中已內建的較新版 huggingface_hub, 好吧!反正 Faster Whisper 目前只要 0.13 版以上就能運作,就先安裝舊版的 huggingface_hub,在筆記本安裝 Faster Whipser 的程序前,加上了:

!pip -q install huggingface_hub==0.19.4

哈!先求能動,等不行時再來想別的辦法。

後記:(2024.01.08)

huggingface_hub 已經有最新版 (0.20.2)可以解決 Colab 卡住的問題,所以安裝最新版的 huggingface_hub  也能解決問題,用這道指令來安裝最新版的 huggingface_hub:

!pip install -q -U huggingface_hub


相關文章

沒有留言:

張貼留言

 
雄::gsyan © 2009. Design by Pocket