Enhance Your Images: A Developer's Guide to the mamorett/samothraki-upscaler Cognitive Actions

23 Apr 2025
Enhance Your Images: A Developer's Guide to the mamorett/samothraki-upscaler Cognitive Actions

In the world of image processing, enhancing the quality and details of images is a critical task. The mamorett/samothraki-upscaler provides a powerful set of Cognitive Actions designed to upscale and enhance images while preserving their original features. By leveraging advanced algorithms, developers can integrate these pre-built actions into their applications, allowing for seamless and efficient image enhancement.

Prerequisites

Before diving into the Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic understanding of how to make API calls and handle JSON data.

To authenticate your requests, you will typically pass the API key in the headers of your HTTP requests.

Cognitive Actions Overview

Enhance Image Details

The Enhance Image Details action is designed to upscale and enhance images, ensuring that original features are preserved. This action falls under the image-enhancement category and offers a variety of parameters to tailor the output to your needs.

Input: The action requires an input JSON object that includes the following fields:

  • image (string, required): The URI of the image to be processed. It must be a valid URI.
  • denoise (number, optional): The level of denoising to apply. Defaults to 1.0.
  • upscaler (string, optional): The method used to upscale the image. Options include "4x_NMKD-Siax_200k" and "4xSSDIRDAT", with a default of "4x_NMKD-Siax_200k".
  • upscaleBy (number, optional): Factor by which to upscale the image. Defaults to 2.
  • guidanceScale (number, optional): Scale for guidance during processing, with a default of 3.
  • calculateTiles (boolean, optional): Whether to calculate tile size automatically. Defaults to false.
  • colorCorrection (boolean, optional): Apply wavelet color correction. Defaults to true.
  • numInferenceSteps (integer, optional): Number of steps for inference during processing. Defaults to 20.
  • hdrEffectIntensity (number, optional): Intensity of the HDR effect to apply. Defaults to 0.

Example Input:

{
  "image": "https://replicate.delivery/pbxt/MXKxGd3rAIynZHXnoOl2yfdABF9IgOJ6pTQUGbAoff6sjWBv/Trithemiana%201.0_00001___0012.png_realvisxlV50_v50Bakedvae_0001.png_flux_dev8_0002.png",
  "denoise": 1,
  "upscaler": "4x_NMKD-Siax_200k",
  "upscaleBy": 2,
  "guidanceScale": 3,
  "colorCorrection": true,
  "numInferenceSteps": 20,
  "hdrEffectIntensity": 0
}

Output: The action typically returns a JSON array containing the URIs of enhanced images. For example:

[
  "https://assets.cognitiveactions.com/invocations/36e9e8e9-314c-447f-af06-d31f75e21a40/c797e3e8-f439-44f4-a7e1-7805b6c543da.png"
]

Conceptual Usage Example (Python): Here’s how you might call the Enhance Image Details 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 = "8aa526ac-3600-44e7-bd2e-31602d585d02" # Action ID for Enhance Image Details

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/MXKxGd3rAIynZHXnoOl2yfdABF9IgOJ6pTQUGbAoff6sjWBv/Trithemiana%201.0_00001___0012.png_realvisxlV50_v50Bakedvae_0001.png_flux_dev8_0002.png",
    "denoise": 1,
    "upscaler": "4x_NMKD-Siax_200k",
    "upscaleBy": 2,
    "guidanceScale": 3,
    "colorCorrection": true,
    "numInferenceSteps": 20,
    "hdrEffectIntensity": 0
}

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, you replace YOUR_COGNITIVE_ACTIONS_API_KEY with your valid API key and send a POST request to the hypothetical execution endpoint. The payload is structured according to the input schema of the action.

Conclusion

Integrating the mamorett/samothraki-upscaler Cognitive Actions into your applications can significantly enhance image quality and detail. By leveraging the Enhance Image Details action, you can offer users a seamless experience in image enhancement. Consider exploring other potential use cases and experimenting with different parameters to fully utilize the capabilities of this powerful tool. Happy coding!