Need some help to convert binary previews into images when using websocket example
I want to see the Ksampler preview when using the websocket, and I modified the example in https://github.com/comfyanonymous/ComfyUI/blob/master/script_examples/websockets_api_example.py. The modification begins from line 32.
while True:
out = ws.recv()
if isinstance(out, str):
message = json.loads(out)
print(message)
else:
print(out)
image_file = BytesIO(out)
image.show()
I do get something binary, but I cannot convert it into an image. It seems that it is not a binary image. What should I do to get the preview images? thank you for your help.
https://github.com/comfyanonymous/ComfyUI/commit/a28a9dc83684624ee2167c0b92d976bb68f2c606
I added an example.
Hello, Thanks for the example, I tried it but I never get a "complete" status :
"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 0}}, "sid": "bb116919-f293-4df5-af46-84d728f96265"}}
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 1}}}}
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 1}}}}
{"type": "progress", "data": {"value": 0, "max": 1, "prompt_id": "da75333e-dc76-45c9-b3fb-5cd4641a9ade", "node": null}}
out : b'\x00\x00\x00\x01\x00\x00\x00\x02\x89PNG\r\n\x1a\n\x00\x00
[....]
.!\xfa\x00\x00\x00\x00IEND\xaeB`\x82'
{"type": "status", "data": {"status": {"exec_info": {"queue_remaining": 0}}}}
When I use the history, I don't have any image either. is that normal ?
I tried with a workflow generated by comfyui too and I got the same problem