Enhance Your Images with Supir's Super Resolution Action

In the digital age, high-quality visuals are essential for engaging content and effective communication. Supir offers a powerful Cognitive Action that allows developers to enhance the quality and resolution of low-quality images using advanced techniques. With Supir's Super Resolution action, you can transform your images, making them sharper, more detailed, and visually appealing.
This action is particularly beneficial for industries that rely heavily on imagery, such as e-commerce, photography, and digital media. Whether you're looking to improve product photos for better conversion rates, enhance artwork for print, or refine images for presentations, this action provides a quick and effective solution. By leveraging Supir's capabilities, developers can elevate the quality of their applications and deliver a superior user experience.
Prerequisites
To get started with Supir's Super Resolution, you will need a Cognitive Actions API key and a basic understanding of making API calls.
Enhance Image Quality with Super Resolution
The Super Resolution action enhances the quality and resolution of low-quality images. By utilizing advanced features such as upsampling and color correction, it addresses the common problem of poor image fidelity, particularly under light degradations. This action is categorized under image enhancement, making it an ideal choice for developers looking to improve visual content.
Input Requirements
The input for this action requires a structured request that includes:
- image: A URI pointing to the low-quality input image.
- upscale: An integer indicating the upsampling ratio (default is 1).
- scaleCfg: A number that controls the classifier-free guidance scale (default is 7.5).
- modelName: The specific model to use, with options like "SUPIR-v0Q" for default settings or "SUPIR-v0F" for enhanced quality.
- Additional parameters such as color correction type, noise levels, and prompts for refining the output.
Example Input:
{
"image": "https://replicate.delivery/pbxt/KTLVJXCM9ezJK0VXD1hfRvsOgFQ94ZrsNc6Lw7F4hoMzhCJ4/1703062309551-1024.png",
"upscale": 2,
"scaleCfg": 7.5,
"modelName": "SUPIR-v0F",
"colorFixType": "Wavelet"
}
Expected Output
The expected output is a high-resolution image that showcases improved detail and clarity, making it suitable for various applications. An example output might look like:
https://assets.cognitiveactions.com/invocations/e1290b50-779f-404f-8e5c-5ce22631bc91/35092993-9714-4689-a3db-4c6c21ef1e91.png.
Use Cases for this Specific Action
- E-commerce: Enhance product images to attract customers and increase sales by providing clear and detailed visuals.
- Photography: Improve the quality of photos taken in low-light conditions, ensuring that details are preserved and vibrant.
- Digital Media: Refine images for marketing materials, presentations, or social media posts to ensure a professional appearance.
- Art Restoration: Use the action to recover details in scanned artworks, providing digital restorations that maintain the integrity of the original piece.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "2c52ea3d-2c61-4908-9ff8-9b5675ba1979" # Action ID for: Enhance Image Quality with Super Resolution
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"image": "https://replicate.delivery/pbxt/KTLVJXCM9ezJK0VXD1hfRvsOgFQ94ZrsNc6Lw7F4hoMzhCJ4/1703062309551-1024.png",
"upscale": 2,
"scaleCfg": 7.5,
"useLlava": true,
"linearCfg": false,
"modelName": "SUPIR-v0F",
"scaleChurn": 5,
"scaleNoise": 1.003,
"minimumSize": 1024,
"scaleStage1": -1,
"scaleStage2": 1,
"colorFixType": "Wavelet",
"edmStepCount": 50,
"additivePrompt": "Cinematic, High Contrast, highly detailed, taken using a Canon EOS R camera, hyper detailed photo - realistic maximum detail, 32k, Color Grading, ultra HD, extreme meticulous detailing, skin pore detailing, hyper sharpness, perfect without deformations.",
"negativePrompt": "painting, oil painting, illustration, drawing, art, sketch, oil painting, cartoon, CG Style, 3D render, unreal engine, blurring, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth",
"linearScaleStage2": false,
"startPointLinearCfg": 1,
"startPointLinearScaleStage2": 0
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
Supir's Super Resolution action is a powerful tool that enhances image quality and resolution, providing developers with the ability to deliver visually stunning content. With its ease of use and flexibility, it caters to a wide range of use cases across various industries. By integrating this action into your applications, you can significantly improve the quality of images and enhance user satisfaction.
Consider exploring further applications of Supir's capabilities to elevate your projects and create more engaging experiences for your users.