Unleashing Creativity: Integrating Image Generation with vooseyllc/dajh-v1-0 Cognitive Actions

23 Apr 2025
Unleashing Creativity: Integrating Image Generation with vooseyllc/dajh-v1-0 Cognitive Actions

In the rapidly evolving landscape of artificial intelligence, the ability to generate and manipulate images based on textual prompts is a game-changer for developers. The vooseyllc/dajh-v1-0 API offers powerful Cognitive Actions that enable you to create stunning images using advanced techniques like inpainting and refinement. This article will guide you through the integration of the Cognitive Action for image generation, empowering you to enhance your applications with creative visual content.

Prerequisites

Before diving into the implementation, ensure you have the following:

  • An API key for the Cognitive Actions platform. This key is essential for authenticating your requests to the service.
  • Familiarity with making HTTP requests in your development environment.
  • Conceptual understanding of JSON, as the input and output for the actions will be formatted in this structure.

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

Cognitive Actions Overview

Generate Image with Inpainting and Refinement

This action generates an image using an inpainting technique based on a provided text prompt. It allows for extensive customization through parameters like masks, image dimensions, and refinement styles, ensuring a versatile image creation process.

Input

The action requires a structured JSON payload. Here’s a breakdown of the properties:

  • mask (string): A URI of the input mask. Areas marked in black will remain unchanged, while white areas will be inpainted.
  • seed (integer): A seed value for randomness. Leave blank for a random seed.
  • image (string): A URI of the input image for img2img or inpaint mode.
  • width (integer): The output image’s pixel width (default: 1024).
  • height (integer): The output image’s pixel height (default: 1024).
  • prompt (string): The textual description guiding the image creation.
  • loraScale (number): Scale factor for LoRA addition (default: 0.6, range: 0-1).
  • numOutputs (integer): Number of images to generate (default: 1, max: 4).
  • refineSteps (integer, optional): Number of steps for refining the base image.
  • refineStyle (string): Style for refinement, with options like no_refiner, expert_ensemble_refiner, and base_image_refiner (default: no_refiner).
  • guidanceScale (number): Intensity of classifier-free guidance (default: 7.5, range: 1-50).
  • applyWatermark (boolean): Whether to apply a watermark (default: true).
  • negativePrompt (string): Text to exclude from the image.
  • promptStrength (number): Determines the prompt's influence in img2img or inpaint modes (default: 0.8, range: 0-1).
  • schedulingMethod (string): Algorithm for scheduling inference (default: K_EULER).
  • numInferenceSteps (integer): Denoising steps (default: 50, range: 1-500).
  • disableSafetyChecker (boolean): Toggle to disable the safety checker (default: false).

Here’s an example of the JSON input for this action:

{
  "seed": 1,
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of DAJH, a DAJH 5 bedroom mountain modern home propped up on stilts above grand prismatic hot spring",
  "loraScale": 0.9,
  "numOutputs": 1,
  "refineStyle": "expert_ensemble_refiner",
  "guidanceScale": 12.06,
  "highNoiseFrac": 0.8,
  "applyWatermark": false,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "schedulingMethod": "DPMSolverMultistep",
  "numInferenceSteps": 24
}

Output

The output of this action is a list of generated image URLs. Here’s an example of what you might receive:

[
  "https://assets.cognitiveactions.com/invocations/da623339-f874-4015-9905-f133b964954e/59aa2e46-b29c-4d9e-82fb-7806de544502.png"
]

Conceptual Usage Example (Python)

Here’s how you might call this 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 = "092ab985-a695-4469-9f0b-d142b5694b85"  # Action ID for Generate Image with Inpainting and Refinement

# Construct the input payload based on the action's requirements
payload = {
    "seed": 1,
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of DAJH, a DAJH 5 bedroom mountain modern home propped up on stilts above grand prismatic hot spring",
    "loraScale": 0.9,
    "numOutputs": 1,
    "refineStyle": "expert_ensemble_refiner",
    "guidanceScale": 12.06,
    "highNoiseFrac": 0.8,
    "applyWatermark": False,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "schedulingMethod": "DPMSolverMultistep",
    "numInferenceSteps": 24
}

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 corresponds to the "Generate Image with Inpainting and Refinement" action.
  • The payload is structured based on the required input fields.

Conclusion

The vooseyllc/dajh-v1-0 Cognitive Action for image generation opens up a world of possibilities for developers looking to enhance their applications with dynamic visual content. By leveraging the capabilities of inpainting and refinement, you can create unique images tailored to your specifications. Start experimenting with these actions today to elevate your projects and engage users like never before!