From 13ecf10a920b0a08b01d2216dfbbdfd1aef519e8 Mon Sep 17 00:00:00 2001 From: RandomGitUser321 Date: Sun, 22 Sep 2024 02:30:44 -0400 Subject: [PATCH] Added to the websockets_api_example.py to show how to decode latent previews from the binary stream (#5016) * Update websockets_api_example.py * even more simplfied --- script_examples/websockets_api_example.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script_examples/websockets_api_example.py b/script_examples/websockets_api_example.py index 62afc869..5e80aace 100644 --- a/script_examples/websockets_api_example.py +++ b/script_examples/websockets_api_example.py @@ -38,6 +38,9 @@ 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: + # bytesIO = BytesIO(out[8:]) + # 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]