Create Stunning Inpainted Images with Hvn's AI Actions

25 Apr 2025
Create Stunning Inpainted Images with Hvn's AI Actions

In today's digital landscape, image generation and manipulation have become integral to various applications, from gaming to marketing. Hvn offers a powerful set of Cognitive Actions that facilitate the creation of inpainted images using advanced image-to-image techniques. With the ability to optimize for quality or speed, developers can leverage these actions to enhance their projects, streamline workflows, and produce visually stunning content with minimal effort.

The Generate Inpainted Image action allows you to create images based on detailed prompts, enabling you to generate unique visuals that align with your creative vision. Whether you're looking to produce concept art, design elements for apps, or even marketing materials, this action simplifies the process while offering flexibility in terms of output quality and speed.

Prerequisites

To utilize Hvn's Cognitive Actions, you'll need an API key and a basic understanding of making API calls.

Generate Inpainted Image

The Generate Inpainted Image action is designed to create images by employing advanced inpainting techniques. This action is particularly useful for developers looking to fill in missing parts of images or generate entirely new visuals based on specific prompts.

  • Input Requirements: The action requires a prompt that describes the desired image. You can also provide an input image or a mask for inpainting mode. Additional parameters like model choice, aspect ratio, and output format allow for customization.
  • Expected Output: The output will be a generated image that aligns with the input prompt, either as a URL link to the image file or as a binary image data, depending on the request.
  • Use Cases for this specific action:
    • Concept Art Creation: Artists and game developers can generate detailed concept art based on imaginative prompts.
    • Marketing Materials: Businesses can create unique visuals for advertising campaigns or social media posts tailored to specific themes.
    • Visual Content for Apps: Developers can produce graphics that fit their application's aesthetic, enhancing user 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 = "3461e8d4-91b0-4224-b386-5c3a776762dd" # Action ID for: Generate Inpainted Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "prompt": "An eerie, surreal scene of an endless office hallway with a dark blue-green tint and dramatic lighting inspired by a desolate landscape under an ominous sky. The ceiling panels are missing, exposing wires and pipes above, while sections of the carpet below show patches of mold, adding a sense of decay. The hallway stretches indefinitely, with flickering lights casting uneven shadows and a subtle red glow reminiscent of an otherworldly sun, creating a haunting atmosphere. Distorted, ghostly figures resembling asylum patients appear sporadically down the hallway, some crouching in the corners, others wandering aimlessly, their faces obscured by shadows. These figures are dressed in torn, faded hospital gowns, their movements twitchy and unnatural, reminiscent of Silent Hill’s haunting aesthetic. The walls are lined with outdated office doors and cubicles that seem to repeat endlessly, amplifying the unsettling, surreal feel. The overall ambiance is otherworldly, capturing a blend of emptiness, quiet unease, and distant menace.",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "9:16",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "numInferenceSteps": 28
}

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
Hvn's Generate Inpainted Image action provides a robust solution for developers seeking to create visually compelling images tailored to their specific needs. By leveraging this action, you can enhance your projects with high-quality visuals, streamline your creative process, and explore new artistic possibilities. Start integrating Hvn's Cognitive Actions into your workflow today to unlock the full potential of image generation!