Generate Stunning Image Variations with Adirik Local Prompt Mixing Actions

21 Apr 2025
Generate Stunning Image Variations with Adirik Local Prompt Mixing Actions

In the world of image processing and generation, the Adirik Local Prompt Mixing API brings powerful capabilities to developers looking to create tailored and unique visual content. With actions designed for generating object-level shape variations, this API allows you to modify specific elements within an image while preserving the surrounding context. This guide will walk you through the primary Cognitive Action available, detailing its functionality, input requirements, and how to integrate it into your applications.

Prerequisites

Before you start using the Adirik Local Prompt Mixing actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Knowledge of how to make HTTP requests and handle JSON data.
  • Familiarity with Python, as we’ll provide a conceptual usage example in Python.

Authentication typically involves passing your API key in the headers of your requests, allowing you to securely access the API's features.

Cognitive Actions Overview

Generate Object Shape Variations

Description: This action generates object-level shape variations within an image using Stable Diffusion 1.4 while preserving other elements. By employing local prompt mixing, you can modify specified objects in an image based on your directives.

Category: Image Processing

Input: The action requires the following input fields, as detailed in the schema below:

  • image (required): URI of the input image.
  • objectOfInterest (required): The primary object intended for modification.
  • prompt (required): A description of the desired image content.
  • seed (optional): Random seed for generating variations (default: 10, range: 0-100).
  • steps (optional): Total number of denoising steps (default: 50, range: 1-100).
  • proxyWords (optional): Custom proxy words to influence generation (default: auto-generated).
  • guidanceScale (optional): Scale factor for guiding prompt influence (default: 7.5, range: 0-20).
  • endPromptRange (optional): Step at which prompt influence ends (default: 17).
  • startPromptRange (optional): Step at which prompt influence begins (default: 7).
  • objectsToPreserve (optional): Comma-separated list of objects to remain unchanged (default: none).
  • numberOfVariations (optional): Number of variations to generate (default: 1, range: 1-5).

Example Input:

{
  "seed": 10,
  "image": "https://replicate.delivery/pbxt/K2CCi8IiDes9u7OWn2tQsZTtjatbfXsEapZMwWISUrtTMaOo/real.jpg",
  "steps": 50,
  "prompt": "A vase with flowers on the table",
  "proxyWords": "",
  "guidanceScale": 7.5,
  "endPromptRange": 17,
  "objectOfInterest": "vase",
  "startPromptRange": 7,
  "objectsToPreserve": "flowers",
  "numberOfVariations": 2
}

Output: The action typically returns an array of URIs pointing to the generated image variations. An example output might look like this:

[
  "https://assets.cognitiveactions.com/invocations/6d88b280-dd7e-4771-827c-80719c625c49/6363864b-4043-4c6b-8256-ff6f0cfcd2f5.jpg",
  "https://assets.cognitiveactions.com/invocations/6d88b280-dd7e-4771-827c-80719c625c49/4ae38b4f-7ebc-4850-a654-491f94df7cc2.jpg",
  "https://assets.cognitiveactions.com/invocations/6d88b280-dd7e-4771-827c-80719c625c49/0cd2ca96-2b96-47ca-bde2-053247f85e55.jpg",
  "https://assets.cognitiveactions.com/invocations/6d88b280-dd7e-4771-827c-80719c625c49/dc20029d-22c6-4db4-86db-37105a53931a.jpg"
]

Conceptual Usage Example (Python): Here’s how you might call the Generate Object Shape Variations 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 = "6b4767ca-0988-4624-a84c-679d41e0a03c"  # Action ID for Generate Object Shape Variations

# Construct the input payload based on the action's requirements
payload = {
    "seed": 10,
    "image": "https://replicate.delivery/pbxt/K2CCi8IiDes9u7OWn2tQsZTtjatbfXsEapZMwWISUrtTMaOo/real.jpg",
    "steps": 50,
    "prompt": "A vase with flowers on the table",
    "proxyWords": "",
    "guidanceScale": 7.5,
    "endPromptRange": 17,
    "objectOfInterest": "vase",
    "startPromptRange": 7,
    "objectsToPreserve": "flowers",
    "numberOfVariations": 2
}

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 action ID and the input payload structure are tailored to the Generate Object Shape Variations action, demonstrating how to set the required and optional parameters effectively.

Conclusion

The Adirik Local Prompt Mixing Cognitive Action provides a straightforward yet powerful way to enhance and manipulate images, enabling developers to create visually appealing variations tailored to specific needs. With the ability to preserve elements and adjust various parameters, this action can be integrated into applications for a range of creative uses, from graphic design to content creation. Explore further use cases and begin integrating these actions to elevate your image processing capabilities!