Create Stunning Image Variations with the mcai/babes-v2.0-img2img Cognitive Actions

24 Apr 2025
Create Stunning Image Variations with the mcai/babes-v2.0-img2img Cognitive Actions

In today's digital landscape, generating unique and engaging images is more critical than ever. The mcai/babes-v2.0-img2img Cognitive Actions empower developers to create stunning image variations effortlessly. By leveraging the Babes 2.0 model, these pre-built actions provide a robust solution for image customization, allowing for adjustable parameters to influence the output effectively.

Prerequisites

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

  • An active API key for the Cognitive Actions platform. This will be required for authentication when making requests to the API.
  • Basic knowledge of sending HTTP requests and handling JSON data in your programming environment.

Typically, authentication works by including your API key in the request headers, allowing secure access to the Cognitive Actions.

Cognitive Actions Overview

Create Image Variation with Babes 2.0

Description: This action generates a new image variation from an input image using the Babes 2.0 model. You can customize the output based on noise strength, upscale factor, and specific prompts through guidance scaling.

Category: Image Generation

Input:

The input schema for this action requires the following fields:

  • image (string, required): The initial image URL from which to generate variations.
    Example: https://replicate.delivery/pbxt/Ivoso7XB5qRyzARe5YhJKh86I1KeBM256Ri9j9N9ym9NGq6M/image-46-92.jpg
  • prompt (string, optional): A descriptive prompt to influence the generated output.
    Example: Trendy Anthropomorphic bird, MOBA character concept art, 8k, unreal engine
  • upscale (number, optional): The upscale factor for image generation (1 to 4).
    Example: 2
  • strength (number, optional): The degree of noise strength applied during generation (0 to 1).
    Example: 0.5
  • scheduler (string, optional): The type of scheduler used in the denoising process. Default is EulerAncestralDiscrete.
    Example: EulerAncestralDiscrete
  • guidanceScale (number, optional): A scalar for classifier-free guidance, influencing adherence to the prompt (1 to 20).
    Example: 7.5
  • negativePrompt (string, optional): Elements to exclude from the generated output.
    Example: disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry...
  • numberOfOutputs (integer, optional): The number of image variations to generate (1 to 4).
    Example: 1
  • numberOfInferenceSteps (integer, optional): The number of steps for the denoising process (1 to 500).
    Example: 30

Example Input:

{
  "image": "https://replicate.delivery/pbxt/Ivoso7XB5qRyzARe5YhJKh86I1KeBM256Ri9j9N9ym9NGq6M/image-46-92.jpg",
  "prompt": "Trendy Anthropomorphic bird, MOBA character concept art, 8k, unreal engine",
  "upscale": 2,
  "strength": 0.5,
  "scheduler": "EulerAncestralDiscrete",
  "guidanceScale": 7.5,
  "negativePrompt": "disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry...",
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 30
}

Output:

When successfully executed, this action returns a list of generated image URLs. For instance:

[
  "https://assets.cognitiveactions.com/invocations/853cc505-ac29-4b13-8da7-fba4f08aecf3/e4f36812-1641-48e1-ac89-366838a57438.png"
]

Conceptual Usage Example (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 = "73754ed5-77df-4689-8e6b-a51df2aff0e1" # Action ID for Create Image Variation with Babes 2.0

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/Ivoso7XB5qRyzARe5YhJKh86I1KeBM256Ri9j9N9ym9NGq6M/image-46-92.jpg",
    "prompt": "Trendy Anthropomorphic bird, MOBA character concept art, 8k, unreal engine",
    "upscale": 2,
    "strength": 0.5,
    "scheduler": "EulerAncestralDiscrete",
    "guidanceScale": 7.5,
    "negativePrompt": "disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry...",
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 30
}

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 Python code snippet, the action ID and input payload are structured appropriately for the API call. Remember that the endpoint URL and request structure are illustrative and should be adapted to your specific integration scenario.

Conclusion

The mcai/babes-v2.0-img2img Cognitive Actions provide developers with powerful tools for generating unique image variations, enhancing creativity in applications. By leveraging customizable parameters, you can tailor outputs to meet specific needs, making this a valuable addition to any developer's toolkit. Explore these actions further and consider how they can enhance your projects!