DEV Community

Cover image for 在 Windows 執行 Gradio 分享連結的注意事項
codemee
codemee

Posted on

在 Windows 執行 Gradio 分享連結的注意事項

Gradio 是個很棒的工具, 讓我們可以快速幫程式加上簡易又美觀的網頁介面, 不過如果你在 Windows 使用 Gradio, 並且以 launch(share=True) 啟用介面, 很可能會遇到這樣的狀況:

# python .\chat_api.py
Running on local URL:  http://127.0.0.1:7860

Could not create share link, please check your internet connection.
Enter fullscreen mode Exit fullscreen mode

Gradio 說無法建立共享連結, 只能在本機端提供網頁介面。

這可能是你的 Windows Defender 把 Gradio 擋住了, 在 Windows defender 會看到它發現了垃圾軟體:

按一下檢閱, 就可以看到被擋住的項目:

展開就可以發現 Gradio 執行的 frpc_windows_amd64 被當成垃圾軟體了, 只要在動作清單中選取允許在裝置上就可以了:

重新執行剛剛的程式, 就會看到產生分享連結了:

# python .\chat_api.py
Running on local URL:  http://127.0.0.1:7860
Running on public URL: https://6023a743-e9c0-45df.gradio.live

This share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces
Enter fullscreen mode Exit fullscreen mode

提供給大家參考, 這樣就可以隨時提供網頁介面給大家測試你的程式了。

對了, 如果你不知道 Gradio 怎麼唸?開發者有說明, 就是 GRAY-dee-oh。

Latest comments (0)