Create Stunning Art with the Vanitas Cognitive Actions: A Developer's Guide

22 Apr 2025
Create Stunning Art with the Vanitas Cognitive Actions: A Developer's Guide

In today's digital landscape, the ability to generate artistic images using machine learning techniques opens up new creative avenues for developers. The bendedkneeface/vanitas spec offers powerful Cognitive Actions that enable you to create visually stunning vanitas style paintings from input images and textual prompts. This guide will walk you through how to leverage these pre-built actions to enhance your applications with artistic capabilities.

Prerequisites

Before you begin, ensure that you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Familiarity with sending HTTP requests and handling JSON data.

For authentication, you will typically pass your API key in the headers of your requests.

Cognitive Actions Overview

Generate Vanitas Style Paintings

This action generates vanitas style paintings by taking an input image and applying inpainting techniques, guided by a textual prompt. You can customize various properties such as image dimensions, refinement strategies, and more to achieve high-quality outputs.

Input

The Generate Vanitas Style Paintings action requires a structured JSON payload. Here’s a breakdown of the input schema:

  • mask (string, URI): URI of the input mask for inpainting. Black areas are unchanged; white areas are filled.
  • seed (integer, optional): Random seed for variations. Leave empty for a different seed each time.
  • image (string, URI): URI of the input image for img2img or inpainting mode.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Text prompt describing the desired image.
  • refine (string, default: "no_refiner"): Method for refining the image. Options include 'no_refiner', 'expert_ensemble_refiner', and 'base_image_refiner'.
  • applyWatermark (boolean, default: true): Enable/disable a watermark on generated images.
  • scheduleMethod (string, default: "K_EULER"): Method used for scheduling denoising operations.
  • loraScaleFactor (number, default: 0.6): Scale factor for LoRA, used with trained models.
  • numberOfOutputs (integer, default: 1): Number of images to output.
  • refinementSteps (integer, optional): Specify the number of steps to refine the image.
  • highNoiseFraction (number, default: 0.8): Fraction of noise for 'expert_ensemble_refiner'.
  • alternativeWeights (string, optional): URI for alternative LoRA weights.
  • guidanceScaleFactor (number, default: 7.5): Scale factor for classifier-free guidance.
  • inputPromptStrength (number, default: 0.8): Strength of the input prompt during img2img or inpainting.
  • negativeInputPrompt (string, default: ""): Input prompt specifying undesirable aspects to avoid.
  • safetyCheckerDisabled (boolean, default: false): Toggle to disable the safety checker.
  • numberOfInferenceSteps (integer, default: 50): Number of denoising steps used during generation.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "A painting of a lobster in the VNT style",
  "refine": "expert_ensemble_refiner",
  "applyWatermark": false,
  "scheduleMethod": "K_EULER",
  "loraScaleFactor": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "guidanceScaleFactor": 7.5,
  "inputPromptStrength": 0.8,
  "negativeInputPrompt": "Blurry, under exposed, pixelated",
  "numberOfInferenceSteps": 50
}

Output

The action typically returns a list of generated image URLs. Here’s an example of what the output might look like:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/192bb374-26d7-4a38-8770-6fdfac893434/d701cde2-ce63-4607-bd50-8caecdb437d9.png"
]

Conceptual Usage Example (Python)

Here's how you might call this action using a hypothetical cognitive actions endpoint.

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 = "7aa30de6-fc86-470d-b82f-def2c1407508" # Action ID for Generate Vanitas Style Paintings

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "A painting of a lobster in the VNT style",
    "refine": "expert_ensemble_refiner",
    "applyWatermark": False,
    "scheduleMethod": "K_EULER",
    "loraScaleFactor": 0.8,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "guidanceScaleFactor": 7.5,
    "inputPromptStrength": 0.8,
    "negativeInputPrompt": "Blurry, under exposed, pixelated",
    "numberOfInferenceSteps": 50
}

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 example, replace the API key with your own and ensure the action ID and input payload match your desired configuration. The endpoint URL and request structure are illustrative.

Conclusion

The bendedkneeface/vanitas Cognitive Action for generating vanitas style paintings provides a powerful tool for developers looking to integrate artistic image generation into their applications. By utilizing the various customizable parameters, you can create unique and visually appealing outputs tailored to your needs.

Start experimenting with these Cognitive Actions today, and unlock new possibilities for creative expression in your projects!