gradio变量设置

export HF_ENDPOINT=https://hf-mirror.com
export GRADIO_SHARE=True
export GRADIO_SERVER_NAME=0.0.0.0
python -m tools.webui \
    --llama-checkpoint-path "checkpoints/fish-speech-1.2-sft" \
    --decoder-checkpoint-path "checkpoints/fish-speech-1.2-sft/firefly-gan-vq-fsq-4x1024-42hz-generator.pth" \
    --decoder-config-name firefly_gan_vq
HF_ENDPOINT=https://hf-mirror.com GRADIO_SHARE=True GRADIO_SERVER_NAME=0.0.0.0 python -m tools.webui \
    --llama-checkpoint-path "checkpoints/fish-speech-1.2-sft" \
    --decoder-checkpoint-path "checkpoints/fish-speech-1.2-sft/firefly-gan-vq-fsq-4x1024-42hz-generator.pth" \
    --decoder-config-name firefly_gan_vq
### VSCode 中使用 Gradio 进行开发 #### 安装必要的工具和库 为了在 Visual Studio Code (VSCode) 中顺利使用 Gradio 开发,需先安装 Python 和相关依赖项。 确保已安装最新版本的 Python 并配置好环境变量。接着,在项目根目录下创建虚拟环境并激活它: ```bash python -m venv venv source venv/bin/activate # Linux/MacOS venv\Scripts\activate # Windows ``` 通过 pip 工具来安装 Gradio 库和其他可能需要用到的包: ```bash pip install gradio ``` #### 创建简单的 Gradio 应用程序 编写一个基础的应用实例 `app.py` 来展示如何快速搭建 Gradio 接口服务[^1]: ```python import gradio as gr def greet(name): return f'Hello {name}!' demo = gr.Interface(fn=greet, inputs="text", outputs="text") if __name__ == "__main__": demo.launch() ``` 这段代码定义了一个名为 `greet()` 的简单函数作为处理逻辑,并将其封装成 Gradio Interface 对象以便于前端交互操作。最后调用了 launch 方法启动应用服务器。 #### 配置调试选项 对于更复杂的场景,比如希望自定义主机地址(host)、端口号(port),可以调整 `launch()` 函数中的参数设置[^2]: ```python demo.launch(server_name='0.0.0.0', server_port=7860) ``` 这允许应用程序监听指定 IP 地址上的特定端口请求,方便本地网络内的其他设备访问该接口页面。 #### 使用 VSCode 调试功能 利用 VSCode 内建的强大调试器能够极大地提高开发效率。编辑 `.vscode/launch.json` 文件加入如下 JSON 片段以支持 Flask 类似的热重载特性[^3]: ```json { "version": "0.2.0", "configurations": [ { "name": "Python: Gradio App", "type": "python", "request": "launch", "program": "${workspaceFolder}/app.py", "console": "integratedTerminal", "justMyCode": true, "env": {"GRADIO_SERVER_NAME": "0.0.0.0", "GRADIO_SERVER_PORT": "7860"} } ] } ``` 这样就可以直接点击 IDE 右侧边栏里的绿色播放图标一键开启带有断点跟踪等功能的支持了!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值