Create Stunning Visuals with DFToilet2 Cognitive Actions

23 Apr 2025
Create Stunning Visuals with DFToilet2 Cognitive Actions

In the realm of image generation, the DFToilet2 Cognitive Actions provide an innovative approach to creating customized images. By allowing you to integrate DFToilet2 into various scenes, these actions empower developers to generate unique visuals tailored to specific requirements. From adjusting image dimensions to enhancing quality through various parameters, these pre-built actions simplify the process of image creation, making it accessible and efficient.

Prerequisites

To utilize the DFToilet2 Cognitive Actions, you'll need a few things in place:

  • API Key: Sign up for the Cognitive Actions platform and obtain your API key.
  • Setup: Ensure you have the necessary libraries installed (e.g., requests for Python).
  • Authentication: The API key should be passed in the headers for authentication when making requests.

Cognitive Actions Overview

Generate Customized Image Using DFToilet2

Description: This action enables you to create a customized image by incorporating DFToilet2 into various scenes. You can specify the image's details such as width, height, aspect ratio, and style through prompts. Moreover, it allows you to enhance the image quality with parameters like LoRA scales, inference steps, and output formats.

Category: Image Generation

Input

The input schema for this action requires a JSON object with the following fields:

  • prompt (required): A text prompt guiding the image generation.
  • image (optional): URI of the input image used for image-to-image generation or inpainting.
  • mask (optional): URI of the image mask for inpainting.
  • width (optional): Width of the generated image in pixels (only applicable if aspect_ratio is set to 'custom').
  • height (optional): Height of the generated image in pixels (only applicable if aspect_ratio is set to 'custom').
  • modelType (optional): Select the model for inference (dev or schnell).
  • megapixels (optional): Approximate number of megapixels for the generated image.
  • imageFormat (optional): Specifies the format of the output image files (default is webp).
  • outputQuality (optional): Quality of the output images, ranging from 0 to 100.
  • outputQuantity (optional): Defines the number of images to generate (1 to 4).
  • guidanceIntensity (optional): Controls the guidance scale during the diffusion process.
  • inferenceStepCount (optional): Specifies the number of denoising steps in the inference process.
  • imagePromptStrength (optional): Prompt strength when using img2img.
  • Additional fields for LoRA weights and intensities.

Example Input:

{
  "image": "https://replicate.delivery/pbxt/LoBYvev4GJQYAaN0G2RQ1JfbpiDTraUWYt9kMIOUXjunGzKE/istockphoto-528978925-612x612.jpg",
  "prompt": "Add the DFToilet2 into the beach setting. it should be a small part of the scenic beach photo and only take up less than 3% of the total image.\nMake the toilet shorter and with the lid down.",
  "modelType": "dev",
  "imageFormat": "webp",
  "loraIntensity": 1,
  "outputQuality": 90,
  "outputQuantity": 3,
  "imageAspectRatio": "1:1",
  "guidanceIntensity": 3.5,
  "inferenceStepCount": 28,
  "imagePromptStrength": 0.8,
  "additionalLoraIntensity": 1
}

Output

Upon successful execution, this action returns an array of URIs pointing to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/c755d392-0b2c-42f7-8b62-ee512213acb6/6af93e58-7772-4740-b58d-d8cdf77d7961.webp",
  "https://assets.cognitiveactions.com/invocations/c755d392-0b2c-42f7-8b62-ee512213acb6/e69a34d2-875b-4ef3-8cf4-2853179cad23.webp",
  "https://assets.cognitiveactions.com/invocations/c755d392-0b2c-42f7-8b62-ee512213acb6/1c8bdfa5-94d8-466a-b26e-f64f361af120.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the DFToilet2 action in a Python script:

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 = "9d99065a-2b5f-465b-969a-1448d9a30e1d" # Action ID for Generate Customized Image Using DFToilet2

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/LoBYvev4GJQYAaN0G2RQ1JfbpiDTraUWYt9kMIOUXjunGzKE/istockphoto-528978925-612x612.jpg",
    "prompt": "Add the DFToilet2 into the beach setting. it should be a small part of the scenic beach photo and only take up less than 3% of the total image.\nMake the toilet shorter and with the lid down.",
    "modelType": "dev",
    "imageFormat": "webp",
    "loraIntensity": 1,
    "outputQuality": 90,
    "outputQuantity": 3,
    "imageAspectRatio": "1:1",
    "guidanceIntensity": 3.5,
    "inferenceStepCount": 28,
    "imagePromptStrength": 0.8,
    "additionalLoraIntensity": 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 example, you replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID corresponds to the Generate Customized Image Using DFToilet2, and the payload is constructed based on the required input fields. The response will contain the generated image URIs.

Conclusion

The DFToilet2 Cognitive Actions provide a powerful tool for developers looking to create unique and customized images with ease. By leveraging the various parameters available, you can produce high-quality visuals that meet specific needs. Whether you’re working on a creative project or enhancing user-generated content, these actions open up a world of possibilities. Start integrating them into your applications today and explore the creative potential they offer!