diff --git a/script_examples/basic_api_example.py b/script_examples/basic_api_example.py index 242d3175f..4a33c327a 100644 --- a/script_examples/basic_api_example.py +++ b/script_examples/basic_api_example.py @@ -107,14 +107,15 @@ def queue_prompt(prompt): request.urlopen(req) -prompt = json.loads(prompt_text) -#set the text prompt for our positive CLIPTextEncode -prompt["6"]["inputs"]["text"] = "masterpiece best quality man" +if __name__ == "__main__": + prompt = json.loads(prompt_text) + #set the text prompt for our positive CLIPTextEncode + prompt["6"]["inputs"]["text"] = "masterpiece best quality man" -#set the seed for our KSampler node -prompt["3"]["inputs"]["seed"] = 5 - - -queue_prompt(prompt) + #set the seed for our KSampler node + prompt["3"]["inputs"]["seed"] = 5 + res = queue_prompt(prompt) + + print(res) diff --git a/script_examples/websockets_api_example.py b/script_examples/websockets_api_example.py index 57a6cbd9b..efded8c76 100644 --- a/script_examples/websockets_api_example.py +++ b/script_examples/websockets_api_example.py @@ -142,23 +142,25 @@ prompt_text = """ } """ -prompt = json.loads(prompt_text) -#set the text prompt for our positive CLIPTextEncode -prompt["6"]["inputs"]["text"] = "masterpiece best quality man" -#set the seed for our KSampler node -prompt["3"]["inputs"]["seed"] = 5 +if __name__ == "__main__": + prompt = json.loads(prompt_text) + #set the text prompt for our positive CLIPTextEncode + prompt["6"]["inputs"]["text"] = "masterpiece best quality man" -ws = websocket.WebSocket() -ws.connect("ws://{}/ws?clientId={}".format(server_address, client_id)) -images = get_images(ws, prompt) + #set the seed for our KSampler node + prompt["3"]["inputs"]["seed"] = 5 -#Commented out code to display the output images: + ws = websocket.WebSocket() + ws.connect("ws://{}/ws?clientId={}".format(server_address, client_id)) + images = get_images(ws, prompt) -# for node_id in images: -# for image_data in images[node_id]: -# from PIL import Image -# import io -# image = Image.open(io.BytesIO(image_data)) -# image.show() + #Commented out code to display the output images: + + for node_id in images: + for image_data in images[node_id]: + from PIL import Image + import io + image = Image.open(io.BytesIO(image_data)) + image.show()