背景:运行代码在huggingface下载roberta-base-finetuned-dianping-chinese模型之后,打开浏览器输入任何的中文input,文本分类结果都显示Error,以下是解决方案:
在Hello World "Error" Output · Issue #4974 · gradio-app/gradio · GitHub中找到了这个留言:
I had the same error, but I downgraded the pydantic version from 2.2.1 to 1.10.7 and it worked fine. I changed the gradio version a lot, but it wasn't a version issue. I got it working fine with gradio==3.34.0.
大意:在gradio版本3.34.0不变的条件下,将环境里的pydantic包版本下调为1.10.7即可
亲测在gradio版本3.23.0将pydantic版本下降之后也可正常使用
pip install pydantic==1.10.7