Generate Stunning Images with the Crocs Cognitive Actions

22 Apr 2025
Generate Stunning Images with the Crocs Cognitive Actions

In the realm of image generation, the maxvanderwerf/crocs API offers powerful Cognitive Actions that leverage advanced inpainting techniques to create high-quality images. This set of actions allows developers to generate photorealistic visuals with customizable parameters, making it an ideal choice for applications that require dynamic and visually striking imagery.

Integrating these pre-built actions into your applications not only saves time but also enhances the creative possibilities at your fingertips.

Prerequisites

Before diving into the usage of these Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making API calls and handling JSON data.
  • Familiarity with Python for conceptual code examples.

Authentication typically involves passing your API key in the headers of your requests to securely access the API.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action enables developers to create high-quality images by utilizing inpainting techniques. This action supports image-to-image transformations and provides adjustable settings for LoRA scales, prompt intensity, and various output formats. It aims to produce photorealistic results efficiently through customizable parameters.

Input

The input schema for this action requires the following:

  • prompt (required): Text prompt to guide the image generation.
  • mask (optional): URI linking to an image mask for inpainting mode.
  • seed (optional): Seed for random number generation.
  • image (optional): URI linking to an input image for image-to-image transformations.
  • width (optional): Specifies the width of the generated image.
  • height (optional): Specifies the height of the generated image.
  • goFast (optional): Enables faster predictions.
  • numOutputs (optional): Designates the number of image outputs.
  • outputFormat (optional): Specifies the format of the output images.
  • guidanceScale (optional): Guidance scale used in the diffusion process.
  • outputQuality (optional): Quality for saving images.
  • numInferenceSteps (optional): Number of denoising steps.
  • imageAspectRatio (optional): Specifies the aspect ratio for the generated image.

Here’s an example input JSON payload:

{
  "prompt": "Amazing photorealistic picture of an athletic and classy male model in an elegant suit in the casino playing russian roulette, wearing black crocs in the TOK style.",
  "extraLora": "levelsio/analog-film",
  "loraScale": 1.05,
  "numOutputs": 2,
  "outputFormat": "png",
  "guidanceScale": 2.01,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageAspectRatio": "1:1",
  "numInferenceSteps": 50
}

Output

Upon successful execution, this action returns an array of URLs pointing to the generated images. Here’s an example of the output:

[
  "https://assets.cognitiveactions.com/invocations/e8defd45-b69b-497b-ba37-bbd4bf6728ad/85f63abb-3f85-48f6-b868-5f6bdb8d0eb8.png",
  "https://assets.cognitiveactions.com/invocations/e8defd45-b69b-497b-ba37-bbd4bf6728ad/e9f3a625-8af9-40dd-9fa3-4a2159da1670.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet illustrating how to call the Generate Image with Inpainting 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 = "ca9947a2-f358-4566-b6ff-b4b680cceaec"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "Amazing photorealistic picture of an athletic and classy male model in an elegant suit in the casino playing russian roulette, wearing black crocs in the TOK style.",
    "extraLora": "levelsio/analog-film",
    "loraScale": 1.05,
    "numOutputs": 2,
    "outputFormat": "png",
    "guidanceScale": 2.01,
    "outputQuality": 90,
    "extraLoraScale": 1,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageAspectRatio": "1:1",
    "numInferenceSteps": 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 code snippet, replace the placeholder for the API key and endpoint with your actual credentials. The action ID and input payload are structured based on the requirements outlined above.

Conclusion

The maxvanderwerf/crocs Cognitive Actions provide a robust framework for generating stunning images through advanced inpainting techniques. With customizable parameters, developers can achieve high-quality outputs tailored to their specific needs. Consider exploring more use cases or integrating these actions into your applications to enhance their visual impact. Happy coding!