Create Stunning Image Variations with lambdal/image-mixer Cognitive Actions

21 Apr 2025
Create Stunning Image Variations with lambdal/image-mixer Cognitive Actions

In the world of image processing, creativity knows no bounds. The lambdal/image-mixer API offers a powerful Cognitive Action that allows developers to generate unique image variations by blending multiple images together. This action leverages a fine-tuned Image Mixer model from Stable Diffusion, enabling you to combine concepts from different images seamlessly. By integrating this functionality into your applications, you can enhance visual content creation, automate design processes, and explore artistic possibilities.

Prerequisites

Before you start using the lambdal/image-mixer Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which will allow you to authenticate your requests.
  • Basic understanding of making HTTP requests and handling JSON data.

Typically, you will pass the API key in the header of your requests. This can be done using the Authorization header with a Bearer token format.

Cognitive Actions Overview

Generate Image Variations with Image Mixer

This action, Generate Image Variations with Image Mixer, allows you to combine two images to create new visual variations by blending their elements and concepts. It falls under the image-processing category.

Input

The input for this action requires a structured JSON object with the following parameters:

  • image1 (string, required): The URI of the first input image. Must be a valid URL.
    • Example: "https://replicate.delivery/pbxt/JXApblNxjlb4o4AmnxK3BWr9sq4rsVu5LpFQH1kNKOba0nVR/image2.jpeg"
  • image2 (string, required): The URI of the second input image. Must be a valid URL.
    • Example: "https://replicate.delivery/pbxt/JXApbpJ3Z99XxPmhSNxKcbyLiw3tVpatoFuUqP2MsgwKuP0t/image1.jpeg"
  • seed (integer, optional): A seed for random number generation to ensure reproducibility. Default is 0.
  • cfgScale (number, optional): Controls the degree of the guidance scale. Default is 3.5.
  • numberOfSteps (integer, optional): Total number of processing steps. Default is 30.
  • numberOfSamples (integer, optional): Number of samples to generate per input. Default is 1.
  • imageOneStrength (number, optional): Determines the influence of the first image. Default is 1.
  • imageTwoStrength (number, optional): Determines the influence of the second image. Default is 1.

Example Input:

{
  "seed": 0,
  "image1": "https://replicate.delivery/pbxt/JXApblNxjlb4o4AmnxK3BWr9sq4rsVu5LpFQH1kNKOba0nVR/image2.jpeg",
  "image2": "https://replicate.delivery/pbxt/JXApbpJ3Z99XxPmhSNxKcbyLiw3tVpatoFuUqP2MsgwKuP0t/image1.jpeg",
  "cfgScale": 3.5,
  "numberOfSteps": 30,
  "numberOfSamples": 1,
  "imageOneStrength": 1,
  "imageTwoStrength": 1
}

Output

Upon successful execution, the action returns a JSON array containing the URI(s) of the generated image variations.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/1704e168-8d2a-4967-91a1-8c679f2bb0b6/5b22e704-e9ff-48a5-a05e-e464d2ee562f.jpeg"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python snippet demonstrating how to call the Cognitive Actions execution endpoint for this 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 = "48be21b9-610e-47db-a35c-4958e7c577c4"  # Action ID for Generate Image Variations with Image Mixer

# Construct the input payload based on the action's requirements
payload = {
    "seed": 0,
    "image1": "https://replicate.delivery/pbxt/JXApblNxjlb4o4AmnxK3BWr9sq4rsVu5LpFQH1kNKOba0nVR/image2.jpeg",
    "image2": "https://replicate.delivery/pbxt/JXApbpJ3Z99XxPmhSNxKcbyLiw3tVpatoFuUqP2MsgwKuP0t/image1.jpeg",
    "cfgScale": 3.5,
    "numberOfSteps": 30,
    "numberOfSamples": 1,
    "imageOneStrength": 1,
    "imageTwoStrength": 1
}

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 snippet, replace the YOUR_COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual API key and endpoint. The action_id corresponds to the specific action you want to execute, and the payload is structured according to the input schema.

Conclusion

The lambdal/image-mixer Cognitive Action opens up exciting possibilities for image manipulation and creative expression. By blending images seamlessly, you can generate stunning visual content for various applications, from marketing materials to personal projects. Explore the potential of this action in your applications, and start creating unique image variations today!