假设我有一个 python gradio 界面,其文本框位于 html/python 网站的默认“/”路径中,并且我希望界面中的文本响应转移到“/other”中的另一个文本框/界面小路;我们怎样才能做到这一点?
了解 gradio 本身,虽然它是为单个模型构建界面的好方法,但我认为缺点之一是使多个模型具有某种连接是相当具有挑战性的。为了解决这个问题,我尝试使用 fastapi 并将 gradio 应用程序安装在类似于文档的对象实例上
https://gradio.app/sharing-your-app/#mounting-within-another-fastapi-app
尽管我发现在获取输入时遇到麻烦或错误。例如:
'''@app get response returning index and other html here,
with gradio apps embedded in the form of html iframes
'''
inp = gr.Interface(
fn=transcribe,
inputs=[
gr.inputs ...
],
outputs=[]
)
outp = gr.Interface(
fn=transcribe,
inputs=[],
outputs=[
gr.Textbox(...)
],
share=True)
app = gr.mount_gradio_app(app, inp, path='/')
app = gr.mount_gradio_app(app, outp, path='/other')
if __name__ == "__main__":
import uvicorn
uvicorn.run(app)
我可能使用了一些错误的函数,因为我不太熟悉使用gradio接口,所以请分享正确的方法。
我认为你可以使用全局变量来链接接口之间,也可以使用另一个库(例如webbrowser)来打开其他接口的url