stable-diffusion-webui-two-shot: Stopped working suddenly, can't visualize
The extension seems to have stopped working for me. Not sure when.
Whenever I press Visualize, I get an ERROR in the preview window:
The log outputs this:
Traceback (most recent call last):
File "C:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
File "C:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1326, in process_api
data = self.postprocess_data(fn_index, result["prediction"], state)
File "C:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1260, in postprocess_data
prediction_value = block.postprocess(prediction_value)
File "C:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 4457, in postprocess
file = self.img_array_to_temp_file(img, dir=self.DEFAULT_TEMP_DIR)
File "C:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 355, in img_array_to_temp_file
return self.pil_to_temp_file(pil_image, dir, format="png")
TypeError: save_pil_to_file() got an unexpected keyword argument 'format'
And it has worked great up until now. I’m on
version: [v1.3.2](https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/baf6946e06249c5af9851c60171692c44ef633e0) • python: 3.10.9 • torch: 2.0.0+cu118 • xformers: 0.0.17 • gradio: 3.32.0 • checkpoint: [e4a56fa397]
with the latest version of two-shot:
stable-diffusion-webui-two-shot | https://github.com/opparco/stable-diffusion-webui-two-shot | main | 9936c52e | Sun Feb 19 08:40:41 2023 | latest
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 16
Commits related to this issue
- fix serving images that have already been saved without temp files function that broke after updating gradio — committed to AUTOMATIC1111/stable-diffusion-webui by AUTOMATIC1111 a year ago
Hey, I’m not part of the dev on this project and also had the same issue.
I Hotfixed it by modifying the function :
def img_array_to_temp_file(self, arr: np.ndarray, dir: str) -> str:
pil_image = _Image.fromarray(
processing_utils._convert(arr, np.uint8, force_copy=False)
)
return self.pil_to_temp_file(pil_image, dir)
in Automatic1111\stable-diffusion-webui\venv\Lib\site-packages\gradio\components.py
I just changed: return self.pil_to_temp_file(pil_image, dir, format=“png”) to return self.pil_to_temp_file(pil_image, dir) on line 355
The problem was the following : The function img_array_to_temp_file calls pil_to_temp_file (who indeed has the format parameter) BUT This function pil_to_temp_file has been overwritten in Automatic1111\stable-diffusion-webui\modules\ui_tempdir.py
# override save to file function so that it also writes PNG info
gradio.components.IOComponent.pil_to_temp_file = save_pil_to_file
AND The function save_pil_to_file that overwrites pil_to_temp_file does not have a “format” parameter hence the error.It’s hardcoded as “png” with the new function and a default “png” in the old one so you should be fine by applying the hotfix I did.
If they change the save_pil_to_file to allow multiple format it may become interesting to undo the hotfix in the future but it should be good for now at least.
Modify file modules\ui_tempdir.py line 34 add param: format=“png”
@TimonFugier thanks so much. It works again.