Create Stunning Images with Fugazzi's Inpainting Action

26 Apr 2025
Create Stunning Images with Fugazzi's Inpainting Action

In the world of digital content creation, generating high-quality images can be a meticulous and time-consuming task. Fugazzi offers a powerful solution with its Cognitive Action for image inpainting, allowing developers to create stunning visuals efficiently. This action leverages advanced techniques to fill in missing parts of images or to generate entirely new images based on textual prompts. By utilizing customizable parameters, you can control aspects like prompt strength, output quality, and image dimensions, making it adaptable to various use cases.

Imagine a scenario where you need to create visually appealing artwork for a marketing campaign or a unique graphic for a blog post. With Fugazzi’s inpainting capabilities, you can easily transform ideas into reality, ensuring a smooth workflow and high-quality outputs. Whether you’re enhancing existing images or generating new ones from scratch, this action simplifies the process, saving you time while delivering impressive results.

Prerequisites

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

Generate Inpainting Image

The Generate Inpainting Image action enables developers to create images using advanced inpainting techniques. This action is particularly useful when you want to generate images that require specific alterations or enhancements based on a given prompt.

Input Requirements

To use this action, you must provide a JSON object that includes the following key properties:

  • prompt: A text description guiding the image generation. Example: "The year is 1511. A super wide-angle, aerial view captures a Renaissance-era woman running down a cobblestone street."
  • image (optional): A URI of the input image for inpainting.
  • mask (optional): A URI for masking areas in the image.
  • width and height (optional): Specify dimensions if using a custom aspect ratio.
  • outputCount: Number of images to generate (between 1 and 4).
  • outputFormat: Choose between webp, jpg, or png for the output files.
  • Additional parameters like guidanceScale, inferenceModel, and promptStrength allow for further customization.

Expected Output

The action returns an array of generated image URIs based on the provided prompt and parameters. Each URI links to a high-quality image that aligns with your specifications.

Use Cases for this Specific Action

  • Content Creation: Quickly generate unique images for blog posts, social media, or marketing materials.
  • Art and Design: Create artwork based on specific themes or concepts, allowing for artistic exploration without the need for extensive manual labor.
  • Prototyping: Use generated images in prototypes for apps or websites, helping to visualize ideas rapidly.
  • Personal Projects: Enhance personal or creative projects with custom images that meet specific visions.

```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 = "e0e4ed04-91aa-44f0-ba11-aa9bb512b629" # Action ID for: Generate Inpainting Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "image": "https://replicate.delivery/pbxt/MiEBXvxi5I0nAuwDvs6aLIEPJgJ40VrGxyE5YZstuZhFwutN/replicate-prediction-vtw3vrgk9srm80cnrmqa3cy920.jpg",
  "prompt": "The year is 1511. A super wide-angle, aerial view (like a helicopter shot) captures Lugazzi (with SAME DRESS) a Renaissance-era woman, running down a cobblestone street in the morning. ",
  "accelerate": false,
  "aspectRatio": "16:9",
  "outputCount": 4,
  "outputFormat": "jpg",
  "guidanceScale": 2,
  "loraIntensity": 0.9,
  "outputQuality": 95,
  "extraLoraScale": 0.8,
  "inferenceModel": "dev",
  "promptStrength": 0.95,
  "imageMegapixels": "1",
  "inferenceStepCount": 46
}

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
Fugazzi's inpainting action is a game-changer for developers looking to streamline the image generation process. By providing customizable parameters and high-quality outputs, this action opens up a world of creative possibilities. Whether you’re working on commercial projects or personal endeavors, integrating this action into your workflow will enhance your productivity and the quality of your visual content. 

Consider exploring additional features or combining this action with other Cognitive Actions to maximize your creative potential!