解决 TypeError: save_pil_to_file()
在使用Stable Diffusion时,您可能会遇到使用SadTalker插件时出现的报错问题。其中,常见的报错是TypeError: save_pil_to_file() got an unexpected keyword argument ‘format’
报错如下:
File "D:\<mypath>\venv\Lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\<mypath>\venv\Lib\site-packages\gradio\blocks.py", line 1321, in process_api
inputs = self.preprocess_data(fn_index, inputs, state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\<mypath>\venv\Lib\site-packages\gradio\blocks.py", line 1171, in preprocess_data
processed_input.append(block.preprocess(inputs[i]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\<mypath>\venv\Lib\site-packages\gradio\components.py", line 1848, in preprocess
return self._format_image(im)
^^^^^^^^^^^^^^^^^^^^^^
File "D:\<mypath>\venv\Lib\site-packages\gradio\components.py", line 1796, in _format_image
path = self.pil_to_temp_file(
^^^^^^^^^^^^^^^^^^^^^^
TypeError: save_pil_to_file() got an unexpected keyword argument 'format'```
解决方法:
1、在Stable Diffusion安装目录下,找到 requirements_versions.txt文件
2、替换 gradio 的版本为 gradio==3.31.0
3、当启动Stable Diffusion时,它会自动下载并安装3.31.0版本的gradio。