Update websockets_api_example.py

removed the import from inside the loop to outside it to improve the code cleanliness.
This commit is contained in:
Abdelrahman ESMAT 2024-09-14 11:42:38 +03:00 committed by GitHub
parent 369a6dd2c4
commit 9bcd048905
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import json
import urllib.request import urllib.request
import urllib.parse import urllib.parse
server_address = "127.0.0.1:8188" server_address = "127.0.0.1:8188"
client_id = str(uuid.uuid4()) client_id = str(uuid.uuid4())
@ -153,11 +154,10 @@ ws.connect("ws://{}/ws?clientId={}".format(server_address, client_id))
images = get_images(ws, prompt) images = get_images(ws, prompt)
#Commented out code to display the output images: #Commented out code to display the output images:
# for node_id in images:
# for image_data in images[node_id]:
# from PIL import Image # from PIL import Image
# import io # import io
# for node_id in images:
# for image_data in images[node_id]:
# image = Image.open(io.BytesIO(image_data)) # image = Image.open(io.BytesIO(image_data))
# image.show() # image.show()