Create Stunning Images with Shell Theatre's Inpainting Action

26 Apr 2025
Create Stunning Images with Shell Theatre's Inpainting Action

In the world of digital content creation, the ability to generate unique images quickly and effectively can set your projects apart. Shell Theatre offers a powerful Cognitive Action designed to elevate your creative workflow: the "Generate Image with Inpainting." This action harnesses advanced inpainting techniques, allowing developers to create images tailored to specific requirements, such as dimensions, quality, and even artistic style. With the capability to generate images faster than traditional methods, Shell Theatre simplifies the creative process, making it accessible for both seasoned developers and newcomers alike.

Imagine needing a custom image for a marketing campaign, blog post, or social media content. Instead of spending hours or days on design software, you can use the inpainting action to generate striking visuals that align perfectly with your vision. This action is particularly useful for scenarios where you want to modify existing images or create entirely new ones based on specific prompts, enhancing your efficiency and creativity.

Prerequisites

To get started with Shell Theatre's Cognitive Actions, you'll need an API key for access and a fundamental understanding of making API calls.

Generate Image with Inpainting

Purpose

The "Generate Image with Inpainting" action allows you to create images with customizable properties using advanced inpainting techniques. This action is particularly useful when you want to generate images that require specific alterations or unique artistic elements, providing flexibility in both the creation and modification processes.

Input Requirements

To utilize this action, you'll need to provide several input parameters:

  • Prompt: A textual description guiding the image generation (e.g., "a futuristic cityscape").
  • Image and Mask: Optional inputs for inpainting mode, allowing you to specify existing images to modify.
  • Model: Choose between "dev" and "schnell" models, each optimized for different performance needs.
  • Dimensions and Aspect Ratio: Specify width and height, or select a predefined aspect ratio.
  • Quality Settings: Adjust the image quality and output format (e.g., JPG, PNG, WEBP).
  • Additional Parameters: Options for fast mode, guidance scale, and LoRA strength allow for fine-tuning.

Example Input

{
  "model": "dev",
  "height": 920,
  "prompt": "fafhu crustacean village in desert",
  "enableFastMode": false,
  "approxMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "loraStrengthScale": 1,
  "imageOutputQuality": 80,
  "imagePromptStrength": 0.8,
  "guidanceIntensityScale": 3,
  "numberOfInferenceSteps": 28,
  "numberOfGeneratedOutputs": 1,
  "additionalLoraStrengthScale": 1
}

Expected Output

The output will be a URL link to the generated image, providing you with a direct way to access and use your newly created visual.

Example Output

[
  "https://assets.cognitiveactions.com/invocations/67ab55d0-6a1e-462e-be10-02a83e0435e0/3fdee9d1-646e-4343-879f-e4afe0457d3f.webp"
]

Use Cases for this Specific Action

  1. Content Creation: Quickly generate custom images for articles, social media posts, or marketing materials.
  2. Artistic Exploration: Test different artistic styles and concepts without the need for complex software.
  3. Prototyping: Create visuals for prototypes or mockups in design projects, enhancing presentations or pitches.
  4. Game Development: Generate unique textures or backgrounds based on game scenarios, enriching the visual experience.

```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 = "b14f9bfd-5a22-49c4-a8cf-03f750457156" # Action ID for: Generate Image with Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "height": 920,
  "prompt": "fafhu crustacean village in desert",
  "enableFastMode": false,
  "approxMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "loraStrengthScale": 1,
  "imageOutputQuality": 80,
  "imagePromptStrength": 0.8,
  "guidanceIntensityScale": 3,
  "numberOfInferenceSteps": 28,
  "numberOfGeneratedOutputs": 1,
  "additionalLoraStrengthScale": 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
Shell Theatre's "Generate Image with Inpainting" action revolutionizes the way developers can create and modify images, offering speed, flexibility, and customization. With its user-friendly interface and powerful capabilities, this action is an invaluable tool for anyone involved in digital content creation. Explore the possibilities of generating stunning visuals tailored to your needs, and take your projects to the next level with Shell Theatre's innovative Cognitive Actions.