comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
52.75k stars 5.57k forks source link

Need some help to convert binary previews into images when using websocket example #3115

Open Eli-U-Chan opened 6 months ago

Eli-U-Chan commented 6 months ago

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.

comfyanonymous commented 6 months ago

https://github.com/comfyanonymous/ComfyUI/commit/a28a9dc83684624ee2167c0b92d976bb68f2c606

I added an example.

RousseauRemi commented 1 month ago

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