ComfyUI
ComfyUI copied to clipboard
Where are KSampler Previews saved?
I am deploying comfy via a cloud server and trying to save the previews for KSampler during each step so that I can show the image result progress over time. Does anyone know where the KSampler previews are saved or how to access that image data?
They are not saved anywhere, those previews are image information sent with the websocket.
Thanks for the clarification! Is there any way to save those images to some custom folder in the ComfyUI director? I want to save them on my cloud instance and return images from each step to show the progress of the image generation.
I am deploying comfy via a cloud server and trying to save the previews for KSampler during each step so that I can show the image result progress over time. Does anyone know where the KSampler previews are saved or how to access that image data?
If you want to save progresses. You can use KSampler Progress node in Inspire Pack.
image information sent with the websocket.
How to get the final image with python?
image information sent with the websocket.
How to get the final image with python?
Just open with Pillow the buffer received for message PREVIEW_IMAGE and that is it?
Here is the code that actually sends previews to client: https://github.com/comfyanonymous/ComfyUI/blob/72508a8d19121e2814ea4dfbce8a5311f37dcd61/server.py#L568-L590
Thanks @bigcat88 but i don't get it How we can use PREVIEW_IMAGE to get the final image? in the example file they track the curent node
def get_images(ws, prompt):
prompt_id = queue_prompt(prompt)['prompt_id']
output_images = {}
current_node = ""
while True:
out = ws.recv()
if isinstance(out, str):
message = json.loads(out)
if message['type'] == 'progress':
data = message['data']
current_step = data['value']
if current_step != 0:
print(str(int(100*current_step/steps))+'% Step: ', current_step, ' of: ', data['max'])
if message['type'] == 'executing':
data = message['data']
if data['prompt_id'] == prompt_id:
if data['node'] is None:
break #Execution is done
else:
current_node = data['node']
else:
if current_node == 'save_image_websocket_node':
images_output = output_images.get(current_node, [])
images_output.append(out[8:])
output_images[current_node] = images_output
return output_images
From the example:
The simple algorithm is like this:
- if
bytesarrived via websocket(add check withisinstancefor that), check the first 4 bytes, if there is a number equal to ONE, then it is PREVIEW_IMAGE message. - Check the next 4 bytes, if there is a number ONE, it means JPEG, if the number is 2, then it means PNG (this can be seen in my previous message from the ComfyUI source codes)
P.S: the example in ComfyUI simply skips all these 8 bytes: out[8:]
Is there any way to write the preview images out to the "output" or "temp" folders? Like a custom node or something? that would be the easiest way for accessing the information via a cloud deployment for ComfyUI.
Is there any way to write the preview images out to the "output" or "temp" folders? Like a custom node or something? that would be the easiest way for accessing the information via a cloud deployment for ComfyUI.
Do you want real-time preview information while the progress is being made, or do you simply want to save the process?
If you want real-time feedback, regardless of how it's done, web socket feedback is necessary to fetch information in real-time while the execution is ongoing.
If you simply need images of the process, you can convert intermediate process images obtained through KSampler Progress from the previously mentioned Inspire Pack into VAE Decode and save them as save image.
Yes I am looking for real-time feedback. Did anyone manage to implement that? I am going to take a crack at it this week.