Enhance Your Images with mserro/upscaler-pro Cognitive Actions

In the digital age, high-quality visuals are paramount. The mserro/upscaler-pro API offers a powerful solution for developers looking to enhance image resolution and restoration through AI-driven technology. With the Enhance Image Resolution and Restoration Cognitive Action, you can transform low-resolution images into stunning, high-quality visuals. This pre-built action leverages advanced models like Stable Diffusion, making it ideal for projects that require photorealistic results.
Prerequisites
Before you dive into integrating the Cognitive Actions, ensure you have the following:
- API Key: You will need a valid API key to authenticate requests to the Cognitive Actions platform.
- Setup: Familiarize yourself with how to send HTTP requests and handle JSON payloads, as this action will require you to format your data accordingly.
Conceptually, you will typically pass your API key in the request headers using the following structure:
Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY
Content-Type: application/json
Cognitive Actions Overview
Enhance Image Resolution and Restoration
The Enhance Image Resolution and Restoration action is designed to upscale and restore images, ensuring they maintain a high level of detail and quality. This action is particularly useful for applications where image fidelity is crucial, such as in art restoration, gaming graphics, or e-commerce.
Category: image-enhancement
Input
The action accepts a composite request that includes several fields, with image being mandatory. Below is the schema:
- image (string, required): URI of the input image to be processed.
- mask (string, optional): URI of a mask image to specify areas that should remain unchanged.
- seed (integer, optional): Random seed for deterministic outputs (default: 1337).
- prompt (string, optional): Text prompt for guiding image generation (default:
"masterpiece, best quality, highres, <lora:more_details:0.5> <lora:SDXLrender_v2.0:1>"). - dynamic (number, optional): Strength of dynamic range expansion (default: 6).
- handFix (string, optional): Options for improving hand clarity (default:
"disabled"). - sharpen (number, optional): Sharpening level after upscaling (default: 0).
- creativity (number, optional): Level of creative interpretation (default: 0.35).
- downscaling (boolean, optional): Whether to downscale before upscaling (default: false).
- resemblance (number, optional): Strength of resemblance to the original image (default: 0.6).
- scaleFactor (number, optional): Multiplier for image dimension increase (default: 2).
- tilingWidth (integer, optional): Width of tiles for processing (default: 112).
- tilingHeight (integer, optional): Height of tiles for processing (default: 144).
- loraFileLinks (string, optional): Comma-separated URIs of LoRA files.
- schedulerType (string, optional): Scheduling algorithm used (default:
"DPM++ 3M SDE Karras"). - outputImageFormat (string, optional): Format of the output image (default:
"png"). - negativePromptText (string, optional): Text to avoid in the image (default:
"(worst quality, low quality, normal quality:2) JuggernautNegative-neg"). - stableDiffusionModel (string, optional): Specific Stable Diffusion model checkpoint (default:
"juggernaut_reborn.safetensors [338b85bc4f]"). - numberOfInferenceSteps (integer, optional): Total denoising steps (default: 18).
- customStableDiffusionModel (string, optional): Custom model if needed.
- downscalingResolutionValue (integer, optional): Target resolution for downscaling (default: 768).
Example Input:
{
"seed": 1337,
"image": "https://replicate.delivery/pbxt/L0jFLiSGvFQV0OrL4EcAKtpTXiG1UfMoRZ3YJGf8JwtM44yx/cat07blowres_p.png",
"prompt": "masterpiece, best quality, highres, <lora:more_details:0.5> <lora:SDXLrender_v2.0:1>",
"dynamic": 6,
"handFix": "disabled",
"sharpen": 0,
"creativity": 0.35,
"downscaling": false,
"resemblance": 0.6,
"scaleFactor": 2,
"tilingWidth": 112,
"tilingHeight": 144,
"loraFileLinks": "",
"schedulerType": "DPM++ 3M SDE Karras",
"outputImageFormat": "png",
"negativePromptText": "(worst quality, low quality, normal quality:2) JuggernautNegative-neg",
"stableDiffusionModel": "juggernaut_reborn.safetensors [338b85bc4f]",
"numberOfInferenceSteps": 18,
"customStableDiffusionModel": "",
"downscalingResolutionValue": 768
}
Output
Upon successful execution, the action typically returns a URI for the enhanced image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/f59d0df9-2037-4dae-a86c-ba4e9611a5bb/533b6fd9-ae88-41da-9723-94ce3d6b24b6.png"
]
Conceptual Usage Example (Python)
Here's a simplified conceptual example of how you can call this action using Python:
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 = "f63004cf-4ccc-4b0c-9da6-b01b082f9022" # Action ID for Enhance Image Resolution and Restoration
# Construct the input payload based on the action's requirements
payload = {
"seed": 1337,
"image": "https://replicate.delivery/pbxt/L0jFLiSGvFQV0OrL4EcAKtpTXiG1UfMoRZ3YJGf8JwtM44yx/cat07blowres_p.png",
"prompt": "masterpiece, best quality, highres, <lora:more_details:0.5> <lora:SDXLrender_v2.0:1>",
"dynamic": 6,
"handFix": "disabled",
"sharpen": 0,
"creativity": 0.35,
"downscaling": false,
"resemblance": 0.6,
"scaleFactor": 2,
"tilingWidth": 112,
"tilingHeight": 144,
"loraFileLinks": "",
"schedulerType": "DPM++ 3M SDE Karras",
"outputImageFormat": "png",
"negativePromptText": "(worst quality, low quality, normal quality:2) JuggernautNegative-neg",
"stableDiffusionModel": "juggernaut_reborn.safetensors [338b85bc4f]",
"numberOfInferenceSteps": 18,
"customStableDiffusionModel": "",
"downscalingResolutionValue": 768
}
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}")
This code snippet outlines how to set up the API call, define the action ID, and format the input payload correctly. Make sure to replace the API key and endpoint with your actual credentials.
Conclusion
The mserro/upscaler-pro Cognitive Action for enhancing image resolution is a powerful tool for any developer looking to improve image quality in their applications. By utilizing this action, you can integrate advanced image processing capabilities with minimal effort. Explore its potential in various use cases, from media and entertainment to e-commerce and digital art restoration, and start creating stunning visuals today!