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
This commit is contained in:
RandomGitUser321 2024-09-22 02:30:44 -04:00 committed by GitHub
parent 7a415f47a9
commit 13ecf10a92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -38,6 +38,9 @@ def get_images(ws, prompt):
if data['node'] is None and data['prompt_id'] == prompt_id: if data['node'] is None and data['prompt_id'] == prompt_id:
break #Execution is done break #Execution is done
else: 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 continue #previews are binary data
history = get_history(prompt_id)[prompt_id] history = get_history(prompt_id)[prompt_id]