Generate Stunning Images with the mcai/realistic-vision-v2.0-img2img Cognitive Actions

22 Apr 2025
Generate Stunning Images with the mcai/realistic-vision-v2.0-img2img Cognitive Actions

Integrating advanced image generation capabilities into your applications can significantly enhance user experience and creativity. The mcai/realistic-vision-v2.0-img2img spec offers a powerful Cognitive Action that allows developers to generate new images based on existing ones using the state-of-the-art Realistic Vision V2.0 model. This action enables customization through various settings, such as upscaling, noise strength, and guidance scale, providing a versatile tool for developers seeking to implement sophisticated image manipulation features.

Prerequisites

Before you can start using the Cognitive Actions, you'll need to meet a few general requirements:

  • API Key: You must have an API key for the Cognitive Actions platform.
  • Setup: Ensure you have the necessary libraries installed for making HTTP requests (e.g., requests in Python).

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Image with Realistic Vision V2.0

Purpose:
This action generates a new image from an input image using the Realistic Vision V2.0 model. It allows for detailed customization of the output, enabling developers to specify both positive and negative prompts, adjust upscaling factors, noise strength, and more.

Category: image-generation

Input:

The action requires the following input fields:

  • image (required): URI of the initial image used as a base to generate variations.
    Example:
    https://replicate.delivery/pbxt/IozexUWtwcjxrxFacQvTrOVvNqVS4Vy2Pqry30l8xWLyOr6f/Tidbit_A_blonde_ballerina_in_a_dusty_rose_leotard_and_tutu_exud_f1ab33d5-cd12-49bc-b22d-6c4d14a3cc5e.png
  • prompt (optional): A textual description of desired characteristics for the generated image.
    Example:
    A blonde ballerina in a dusty rose leotard and tutu exudes elegance and tranquility backstage. Cinematic lighting and ray tracing highlight her grace, with theater stage backdrop.
  • upscale (optional): Factor to upscale the generated image (1 to 4). Default is 1.
    Example:
    2
  • strength (optional): Noise strength applied to the initial image (0 to 1). Default is 0.5.
    Example:
    0.5
  • scheduler (optional): Select a scheduling algorithm for generation. Default is EulerAncestralDiscrete.
    Example:
    EulerAncestralDiscrete
  • guidanceScale (optional): Scaling factor for classifier-free guidance (1 to 20). Default is 7.5.
    Example:
    7.5
  • negativePrompt (optional): List of undesirable attributes to avoid in the generated image.
    Example:
    disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry...
  • numberOfOutputs (optional): Number of images to generate (1 to 4). Default is 1.
    Example:
    1
  • numberOfInferenceSteps (optional): Total denoising steps to refine the image (1 to 500). Default is 30.
    Example:
    25

Output:

The action returns an array of generated image URIs.
Example Output:

[
  "https://assets.cognitiveactions.com/invocations/1a8ef803-3397-4544-970d-4accd3ca7024/9faeb1f5-e90c-4ce6-a6bf-50900957fb09.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 = "13e9f7e4-0ae9-457b-a686-efb71624db7c"  # Action ID for Generate Image with Realistic Vision V2.0

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/IozexUWtwcjxrxFacQvTrOVvNqVS4Vy2Pqry30l8xWLyOr6f/Tidbit_A_blonde_ballerina_in_a_dusty_rose_leotard_and_tutu_exud_f1ab33d5-cd12-49bc-b22d-6c4d14a3cc5e.png",
    "prompt": "A blonde ballerina in a dusty rose leotard and tutu exudes elegance and tranquility backstage. Cinematic lighting and ray tracing highlight her grace, with theater stage backdrop.",
    "upscale": 2,
    "strength": 0.5,
    "scheduler": "EulerAncestralDiscrete",
    "guidanceScale": 7.5,
    "negativePrompt": "disfigured, kitsch, ugly, oversaturated, greain, low-res, deformed, blurry...",
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 25
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the action's requirements, and the action ID is set for generating images. The endpoint URL and request structure are illustrative and may vary based on the actual API specifications.

Conclusion

The Generate Image with Realistic Vision V2.0 action opens up exciting possibilities for developers looking to enhance their applications with advanced image generation capabilities. By leveraging this Cognitive Action, you can create stunning visuals tailored to your users' needs. Consider exploring various input configurations to maximize the potential of this tool in your projects. Happy coding!