strange indent

This commit is contained in:
Karl Hudgell 2025-04-01 17:18:22 +01:00
parent db9b9610ab
commit 5ab4d76d4a
2 changed files with 16 additions and 6 deletions

View File

@ -85,5 +85,5 @@ if user_config["frame"]["auto_regen"] == "True":
scheduler.start() scheduler.start()
os.makedirs(image_folder, exist_ok=True) os.makedirs(image_folder, exist_ok=True)
app.run(host="0.0.0.0", port=user_config["frame"]["port"], debug=True) app.run(host="0.0.0.0", port=user_config["frame"]["port"], debug=True)

20
lib.py
View File

@ -77,9 +77,15 @@ def generate_image(file_name: str, comfy_prompt: str) -> None:
api = ComfyApiWrapper(user_config["comfyui"]["comfyui_url"]) api = ComfyApiWrapper(user_config["comfyui"]["comfyui_url"])
wf = ComfyWorkflowWrapper("./workflow_api.json") wf = ComfyWorkflowWrapper("./workflow_api.json")
# Set workflow parameters # Set workflow parameters
wf.set_node_param("KSampler", "seed", random.getrandbits(32)) # Set a random seed for the sampler wf.set_node_param(
wf.set_node_param("CLIP Text Encode (Prompt)", "text", comfy_prompt) # Set the prompt to be used for image generation "KSampler", "seed", random.getrandbits(32)
wf.set_node_param("Save Image", "filename_prefix", file_name) # Set the filename prefix for the generated image ) # Set a random seed for the sampler
wf.set_node_param(
"CLIP Text Encode (Prompt)", "text", comfy_prompt
) # Set the prompt to be used for image generation
wf.set_node_param(
"Save Image", "filename_prefix", file_name
) # Set the filename prefix for the generated image
wf.set_node_param( # Set image dimensions wf.set_node_param( # Set image dimensions
"Empty Latent Image", "width", user_config["comfyui"]["width"] "Empty Latent Image", "width", user_config["comfyui"]["width"]
) )
@ -94,10 +100,14 @@ def generate_image(file_name: str, comfy_prompt: str) -> None:
if not valid_models: if not valid_models:
raise Exception("No valid options available.") raise Exception("No valid options available.")
model = random.choice(valid_models) model = random.choice(valid_models)
wf.set_node_param("Load Checkpoint", "ckpt_name", model) # Set the model to be used for image generation wf.set_node_param(
"Load Checkpoint", "ckpt_name", model
) # Set the model to be used for image generation
# Generate the image using the workflow and wait for completion # Generate the image using the workflow and wait for completion
logging.debug(f"Generating image: {file_name}") logging.debug(f"Generating image: {file_name}")
results = api.queue_and_wait_images(wf, "Save Image") # Queue the workflow and wait for image generation to complete results = api.queue_and_wait_images(
wf, "Save Image"
) # Queue the workflow and wait for image generation to complete
rename_image() # Rename the generated image file if it exists rename_image() # Rename the generated image file if it exists
# Save the generated image to disk # Save the generated image to disk
for filename, image_data in results.items(): for filename, image_data in results.items():