Skip to content

Commit

Permalink
Added to the websockets_api_example.py to show how to decode latent p…
Browse files Browse the repository at this point in the history
…reviews from the binary stream (#5016)

* Update websockets_api_example.py

* even more simplfied
  • Loading branch information
RandomGitUser321 committed Sep 22, 2024
1 parent 7a415f4 commit 13ecf10
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions script_examples/websockets_api_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 13ecf10

Please sign in to comment.