Transform Your Images with the ola-scooter Cognitive Actions

22 Apr 2025
Transform Your Images with the ola-scooter Cognitive Actions

In the fast-evolving world of image processing, the ola-scooter Cognitive Actions offer powerful capabilities to enhance and transform images using advanced algorithms. These pre-built actions allow developers to integrate sophisticated image manipulation features into their applications easily. Whether you're looking to create stunning visuals or perform specific image transformations, these actions provide the flexibility and performance needed to elevate your projects.

Prerequisites

Before diving into the integration of the ola-scooter Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which will be used for authentication.
  • Basic knowledge of how to make HTTP requests and handle JSON data.
  • The necessary libraries installed in your development environment, such as requests for Python.

Authentication typically involves including your API key in the request headers, allowing secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate Transformed Image

The Generate Transformed Image action creates enhanced images based on a selected base image and a variety of customizable parameters. This action supports features like inpainting, image-to-image transformation, and offers fast performance options through different models.

Input

The input for this action is defined by the following schema:

{
  "prompt": "Photo of a man riding TOK",
  "width": 1024,
  "height": 1024,
  "outputCount": 1,
  "guidanceScale": 7.5,
  "loraIntensity": 0.6,
  "promptStrength": 0.8,
  "numInferenceSteps": 50
}
  • Required Fields:
    • prompt: A string that describes the desired image output. This should include relevant keywords to influence the generated outcome.
  • Optional Fields:
    • mask: A URI for image masks used in inpainting mode.
    • seed: An integer for setting a random seed.
    • image: A URI for the input image.
    • aspectRatio, width, height: Define the dimensions of the generated image.
    • Additional parameters such as guidanceScale, loraIntensity, and numInferenceSteps allow for fine-tuning the generation process.

Output

Upon successful execution, the action returns a URL pointing to the generated image, similar to the following example:

[
  "https://assets.cognitiveactions.com/invocations/6af12e54-1282-47e5-9b30-1b94230cd032/2ffa3f08-50c0-4f4a-bc05-2fafb4060445.webp"
]

This URL can be directly used for displaying the generated image in your application.

Conceptual Usage Example (Python)

Here’s a conceptual Python snippet demonstrating how to call the Generate Transformed Image 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 = "584b404e-c2a9-4ef1-95de-180cd576a76b"  # Action ID for Generate Transformed Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "Photo of a man riding TOK",
    "width": 1024,
    "height": 1024,
    "outputCount": 1,
    "guidanceScale": 7.5,
    "loraIntensity": 0.6,
    "promptStrength": 0.8,
    "numInferenceSteps": 50
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The provided payload is structured according to the action's requirements, allowing you to generate a transformed image based on the specified parameters.

Conclusion

The ola-scooter Cognitive Actions provide a robust framework for developers looking to incorporate advanced image transformation capabilities into their applications. By leveraging these actions, you can create stunning visuals that suit your project needs while enjoying the benefits of fast and customizable image processing.

Ready to transform your images? Start integrating the Generate Transformed Image action today and unlock new creative possibilities!