Create Stunning Images with Bamboozka's Prediction Action

25 Apr 2025
Create Stunning Images with Bamboozka's Prediction Action

Bamboozka offers a powerful suite of Cognitive Actions designed to simplify and enhance the image generation process. By harnessing advanced models like 'schnell' and 'dev', developers can create high-quality images tailored to specific requirements. The "Generate Image with Prediction" action stands out by allowing customization through parameters such as masks, seeds, and output formats, enabling developers to produce images that meet their exact needs. This flexibility is particularly beneficial for applications in gaming, marketing, and content creation, where unique and engaging visuals are crucial.

Imagine being able to generate a realistic image of a character in your game or a product for your marketing campaign simply by providing a detailed text prompt. With Bamboozka, you can streamline this process, saving time and resources while enhancing creativity.

Prerequisites

To get started with Bamboozka's Cognitive Actions, you will need an API key and a basic understanding of making API calls.

Generate Image with Prediction

The "Generate Image with Prediction" action is designed to create images tailored to your specifications. Whether you're looking to produce unique artwork or realistic images for various applications, this action can fulfill your needs.

Input Requirements

To utilize this action, you need to provide a prompt that describes the desired image. You can also include optional parameters such as:

  • mask: An image mask for inpainting.
  • seed: A random seed for reproducible results.
  • image: An input image for inpainting or image-to-image transformations.
  • width and height: Dimensions for custom aspect ratios.
  • megapixels: The desired resolution.
  • customWeights: Load specific model weights.
  • loraIntensity and additionalLoraIntensity: Control the strength of LoRA models.
  • denoisingSteps: The number of steps for image refinement.
  • enableFastMode: Speed up processing using quantization.
  • inferenceModel: Choose between 'dev' and 'schnell' for different performance characteristics.
  • Other parameters include numberOfOutputs, promptIntensity, imageAspectRatio, guidanceIntensity, imageOutputFormat, and imageOutputQuality.

Example Input:

{
  "prompt": "Realistic photograph of BAMBOOZKA playing acoustic guitar on a stage. Bamboozka is wearing a plain black t-shirt with a skull on it. Focused expression with mouth closed. Clean shaved, wearing a skull pendant and a silver chain on his right hand.",
  "megapixels": "1",
  "loraIntensity": 1,
  "denoisingSteps": 28,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "imageAspectRatio": "1:1",
  "guidanceIntensity": 3,
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraIntensity": 1
}

Expected Output

The output will be a high-quality image URL based on your input specifications. For example:

[
  "https://assets.cognitiveactions.com/invocations/e0b2d908-2f39-4f31-9ec3-4ae77492627a/0473be1b-b988-4c72-9b85-47df42eedbba.webp"
]

Use Cases for this Action

  • Game Development: Generate realistic character portraits or environments based on detailed descriptions, enhancing storytelling in games.
  • Marketing: Create promotional images for products by simply describing the desired visual elements, streamlining content creation.
  • Artistic Projects: Allow artists to visualize concepts quickly, using AI-driven images as a foundation for further creativity.
  • Social Media Content: Quickly generate eye-catching visuals that can be used for posts, ads, or campaigns, increasing engagement.

```python
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "7a10f203-7517-4748-9a33-da22d96e8b7f" # Action ID for: Generate Image with Prediction

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "Realistic photograph of BAMBOOZKA playing acoustic guitar on a stage. Bamboozka is wearing a plain black t-shirt with a skull on it. Focused expression with mouth closed. Clean shaved, wearing a skull pendant and a silver chain on his right hand. ",
  "megapixels": "1",
  "loraIntensity": 1,
  "denoisingSteps": 28,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "imageAspectRatio": "1:1",
  "guidanceIntensity": 3,
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraIntensity": 1
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Conclusion
Bamboozka's "Generate Image with Prediction" action empowers developers to create unique images effortlessly. By leveraging customizable parameters and advanced AI models, you can meet diverse needs in various industries, from game development to marketing. As you explore this action, consider how it can transform your projects and streamline your workflow. Start integrating Bamboozka today and unlock new creative possibilities!