From eb8b496b96307ef18ea00cdca9b4bccbba5f9b82 Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Sat, 21 Sep 2024 22:53:38 -0400 Subject: [PATCH] Update websockets_api_example.py --- script_examples/websockets_api_example.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script_examples/websockets_api_example.py b/script_examples/websockets_api_example.py index 62afc869c..10de43374 100644 --- a/script_examples/websockets_api_example.py +++ b/script_examples/websockets_api_example.py @@ -38,6 +38,12 @@ def get_images(ws, prompt): if data['node'] is None and data['prompt_id'] == prompt_id: break #Execution is done else: + # If you want to be able to decode the binary stream for latent previews, here is how you can do it: + # event = struct.unpack(">I", out[:4])[0] + # image_data = out[8:] + # if event == 1: + # bytesIO = BytesIO(image_data) + # preview_image = Image.open(bytesIO) # This is your preview in PIL image format, store it in a global continue #previews are binary data history = get_history(prompt_id)[prompt_id]