Unlock Image Generation with the hudsongraeme/semi Cognitive Actions

22 Apr 2025
Unlock Image Generation with the hudsongraeme/semi Cognitive Actions

In today's digital landscape, the ability to generate high-quality images programmatically is a powerful tool for developers. The hudsongraeme/semi API offers a robust set of Cognitive Actions, particularly focused on generating stunning images of Tesla Semi trucks. By leveraging advanced techniques such as inpainting and prompt-based guidance, developers can create visually appealing content efficiently. In this article, we will explore how to integrate the "Generate Enhanced Tesla Semi Images" action into your applications.

Prerequisites

To get started with the Cognitive Actions, you will need an API key for the hudsongraeme/semi platform. This key will be passed in the headers of your requests for authentication purposes. Ensure you have set up your environment to make HTTP requests and have access to a JSON library for handling payloads.

Cognitive Actions Overview

Generate Enhanced Tesla Semi Images

The "Generate Enhanced Tesla Semi Images" action allows developers to produce high-quality images of Tesla Semi trucks using a fine-tuned model. This action supports various features such as inpainting and adjustable settings to refine image quality.

Input

The input for this action is structured as a JSON object. Below are the required and optional fields based on the input_schema:

  • prompt (string): Input text prompt to guide image generation. (e.g., "A real night, darkness photo of white Tesla semi truck driving though flooded street")
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • refine (string, default: "no_refiner"): Selects the style of refinement. Options include "no_refiner", "expert_ensemble_refiner", or "base_image_refiner".
  • scheduler (string, default: "K_EULER"): The algorithm for denoising steps.
  • outputCount (integer, default: 1, range: 1-4): The number of different images to generate.
  • guidanceScale (number, default: 7.5, range: 1-50): Scale for classifier-free guidance.
  • applyWatermark (boolean, default: true): Determines whether to apply a watermark to generated images.
  • inferenceSteps (integer, default: 50, range: 1-500): Total denoising steps in the generation process.
  • negativePrompt (string, default: ""): Specifies aspects to avoid in the generation.
  • Additional fields such as seed, mask, promptIntensity, and others allow for further customization.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "A real night, darkness photo of white Tesla semi truck driving though flooded street",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "outputCount": 1,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "inferenceSteps": 50,
  "negativePrompt": "trailer, excessive height",
  "promptIntensity": 0.8,
  "highNoiseFraction": 0.8,
  "localizationScale": 0.6
}

Output

Upon invoking the action, you will receive a response containing the generated image(s). The output typically includes URLs pointing to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/9f8e586e-98dd-4444-b72f-ad085d014109/f1c694b0-4b37-4007-a1f3-e58e777b0a3f.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 = "fde6caa5-6466-4b23-948a-8721eff035dc"  # Action ID for Generate Enhanced Tesla Semi Images

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "A real night, darkness photo of white Tesla semi truck driving though flooded street",
    "refine": "no_refiner",
    "scheduler": "K_EULER",
    "outputCount": 1,
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "inferenceSteps": 50,
    "negativePrompt": "trailer, excessive height",
    "promptIntensity": 0.8,
    "highNoiseFraction": 0.8,
    "localizationScale": 0.6
}

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 for generating enhanced Tesla Semi images is included in the payload when making the request. The JSON structure for the input matches the expected schema, ensuring a smooth integration.

Conclusion

The hudsongraeme/semi Cognitive Actions provide a powerful tool for generating high-quality images of Tesla Semi trucks, enabling developers to create stunning visual content easily. By utilizing the flexibility of the input schema and customizable parameters, you can tailor the generated images to fit your specific needs. Consider exploring other features and capabilities offered by the API for even more creative possibilities!