Create Stunning High-Resolution Images with the ComfyUI LORA Upscaler

In the world of image processing and generation, the ComfyUI LORA Upscaler offers a powerful set of Cognitive Actions that allow developers to enhance images using advanced models. With the ability to generate high-resolution images based on customizable prompts, this API provides a streamlined method for integrating image generation capabilities into applications. By leveraging predefined model settings and various parameters, you can achieve stunning results tailored to your specific needs.
Prerequisites
Before diving into the integration of the ComfyUI LORA Upscaler Cognitive Actions, ensure that you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of JSON structures and how to make HTTP requests in your preferred programming language.
- Familiarity with Python is beneficial, as this article will include conceptual code snippets for implementation.
Authentication typically involves passing the API key in the request headers, allowing you to securely access the available actions.
Cognitive Actions Overview
Generate Enhanced Images
The Generate Enhanced Images action is designed to produce high-resolution images based on both positive and negative prompts. This action allows you to customize the output with various parameters, such as image size, denoising level, and guidance scale, using models like 'RealESRGAN_x4plus_anime_6B'.
Input
The input schema for this action includes several fields that can significantly influence the output. Here’s a breakdown:
- seed: (integer, optional) A sampling seed for deterministic outputs. If left empty, a random seed will be used.
- width: (integer, optional) Width of the output image in pixels. Default is 512.
- height: (integer, optional) Height of the output image in pixels. Default is 512.
- prompt: (string, required) A string representing the positive prompt guiding image generation.
- denoise: (number, optional) Denoising strength for the image. Default is 1.
- character: (string, optional) Character identifier used in the generation process.
- modelLink: (string, optional) URL to the model file in safetensors format.
- guidanceScale: (number, optional) Guidance scale to influence generation fidelity. Default is 8.
- scalingFactor: (integer, optional) Rescaling multiplier for the output image. Options are 1, 2, or 4. Default is 1.
- inputImageLink: (string, optional) URI link to an input image for processing.
- negativePrompt: (string, optional) A string representing the negative prompt to avoid certain features.
- numberOfImages: (integer, optional) Number of images to generate. Default is 1.
- modelIdentifier: (string, optional) Name of the checkpoint model to be used.
- schedulingMethod: (string, optional) Scheduler method for controlling the generation workflow. Default is 'karras'.
- imageUpscalerModel: (string, optional) Model used to upscale the image. Options include '4x-UltraSharp' and 'RealESRGAN_x4plus_anime_6B'.
- inferenceStepsCount: (integer, optional) Number of steps in the generation process. Default is 20.
- lowRankAdaptationUrl: (string, optional) URLs for LoRA models in safetensors format.
- samplingTechniqueName: (string, optional) Name of the sampling technique used during generation.
- posePreprocessorConfig: (string, optional) Configuration for the pose preprocessor in ControlNet, represented as a JSON string.
Example Input
Here’s an example of how the input JSON payload might look:
{
"width": 1920,
"height": 1080,
"prompt": "(best quality, masterpiece:1.2), (freckles:0.8), 1girl, solo, happy, smile, closed mouth, ultra-detailed, wallpaper, (add_detail:0.8), city, night light, moon, ",
"denoise": 1,
"character": "paimondef",
"guidanceScale": 8,
"negativePrompt": "worst quality, low quality:1.4), cropped, monochrome, zombie, bad anatomy, (((mutation)))), EasyNegative, badquality-embedding, bad face, simple background, bad hands, bad finger",
"schedulingMethod": "normal",
"inferenceStepsCount": 25,
"samplingTechniqueName": "euler"
}
Output
The action typically returns an array of objects containing the URLs of the generated images and any additional flags:
Example Output
Here’s an example of the output you might receive:
[
{
"url": "https://assets.cognitiveactions.com/invocations/96dd27e1-4bfc-4134-b5cf-be04cb557eb8/1755f349-eabb-445d-8d7c-def6c91d07a3.png",
"nsfw": [],
"special": []
}
]
Conceptual Usage Example (Python)
Here’s a conceptual Python snippet illustrating how to invoke the Generate Enhanced Images action:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "0a79b726-a911-4fa9-8ced-7875a44eefef" # Action ID for Generate Enhanced Images
# Construct the input payload based on the action's requirements
payload = {
"width": 1920,
"height": 1080,
"prompt": "(best quality, masterpiece:1.2), (freckles:0.8), 1girl, solo, happy, smile, closed mouth, ultra-detailed, wallpaper, (add_detail:0.8), city, night light, moon, ",
"denoise": 1,
"character": "paimondef",
"guidanceScale": 8,
"negativePrompt": "worst quality, low quality:1.4), cropped, monochrome, zombie, bad anatomy, (((mutation)))), EasyNegative, badquality-embedding, bad face, simple background, bad hands, bad finger",
"schedulingMethod": "normal",
"inferenceStepsCount": 25,
"samplingTechniqueName": "euler"
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this code snippet, make sure to replace the API key and endpoint with your actual values. The action ID and the input payload structure are also highlighted to guide proper implementation.
Conclusion
The ComfyUI LORA Upscaler’s Generate Enhanced Images action provides developers with a versatile tool for creating high-resolution images tailored to specific prompts and requirements. By integrating this action into your applications, you can harness the power of advanced image generation techniques. Consider exploring additional use cases, such as integrating this functionality into creative platforms, games, or any application requiring image enhancement. Happy coding!