You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to create an image using the python API. Below is the code I wrote referring to script_examples/basic_api_example.py.
The code works without errors. But ultimately, I would like to have the data values of the generated image. What should I do?
import json
from urllib import request, parse
import requests
from config import activity_url, img_url, module_text_path
import traceback
import random
def prompt_txt():
f = open("C:/Users/silverfish/Desktop/sd15_imgs/new_prompt_imgs/test.txt", 'r')
prompt = f.read()
f.close()
return prompt
def negative_txt():
f = open("C:/Users/silverfish/Desktop/sd15_imgs/new_prompt_imgs/test_negative.txt", 'r')
negative = f.read()
f.close()
return negative
try:
url = "http://127.0.0.1:8188/prompt"
with open("/static/module_files/workflow_api.json", "r", encoding='utf-8') as file_json:
prompt = json.load(file_json)
prompt["5"]["inputs"]["text_positive"] = prompt_txt()
prompt["5"]["inputs"]["text_negative"] = negative_txt()
prompt["39"]["inputs"]["image"] = "https://cdn.imweb.me/upload/S201910012ff964777e0e3/62f9a36ea3cea.jpg"
prompt["12"]["inputs"]["seed"] = random.randint(1, 2**64)
p = {"prompt": prompt}
data = json.dumps(p).encode('utf-8')
req = requests.post(url, data=data)
print("check:", req)
print("check:", req.json)
print("check:", req.text)
print("check:", req.status_code)
except Exception as e:
print("error:", e)
traceback.print_exc()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to create an image using the python API. Below is the code I wrote referring to script_examples/basic_api_example.py.
The code works without errors. But ultimately, I would like to have the data values of the generated image. What should I do?
Beta Was this translation helpful? Give feedback.
All reactions