Create Stunning Images with Evelyne's Inpainting Action

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

Evelyne is an innovative API designed to empower developers with robust image generation capabilities. One of its standout features is the "Generate Image with Inpainting" action, which allows you to create images using specified masks and prompts. This action is particularly useful for tasks such as restoring images, modifying existing visuals, or generating entirely new artwork based on user-defined criteria. By leveraging Evelyne, developers can enhance their applications with high-quality, customized images swiftly and efficiently.

Imagine a scenario where you need to restore a vintage photo or create a unique visual for a marketing campaign. Evelyne simplifies these tasks by providing a powerful tool that can intelligently fill in gaps or modify images based on the guidance provided in the prompt. This not only saves time but also enhances creativity, enabling developers to offer a more engaging user experience.

Prerequisites

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

Generate Image with Inpainting

The "Generate Image with Inpainting" action is designed to create images based on a user-defined mask and prompts. This feature is particularly valuable in creative fields where image manipulation is common, such as graphic design and digital art.

Purpose

This action solves the challenge of generating high-quality images that meet specific requirements by allowing users to input prompts and masks. It supports both inpainting and image-to-image generation modes, making it versatile for various use cases.

Input Requirements

To utilize this action, you'll need to provide the following inputs:

  • prompt: A descriptive text prompt guiding the image generation process.
  • mask: A URI pointing to the image mask for inpainting (optional).
  • image: A URI for the input image (optional).
  • aspectRatio: Desired aspect ratio for the output image (default is 1:1).
  • width and height: Custom dimensions if aspect ratio is set to custom.
  • Additional parameters like numOutputs, guidanceScale, and outputFormat to further refine the output.

Expected Output

The output will be a generated image based on the provided inputs. For instance, if you specify a mask and a prompt, the action will produce an image that adheres to the defined criteria. The output format can be in webp, jpg, or png, depending on your needs.

Use Cases for this specific action

  • Image Restoration: Perfect for restoring old photographs by filling in missing parts intelligently.
  • Creative Design: Use Evelyne to generate unique images for marketing, social media, or personal projects based on specific themes and styles.
  • Game Development: Create textures or backgrounds dynamically by modifying existing images or generating new ones through prompts.

Here’s an example of how the input and output might look:

Example Input:

{
  "goFast": false,
  "prompt": "photo of evelyneabrahams full black burqa visible smile winking wearing glasses driving tehran 1980s colour looks straight into camera 20 years younger ",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "numInferenceSteps": 28
}

Example Output:

https://assets.cognitiveactions.com/invocations/bd0fd578-5e5d-4814-ab06-59786947ab31/8375960e-837d-41c9-9dcf-ad081b13cb3f.webp
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 = "7f5d398c-c88d-464e-b391-9e5711822f1b" # 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 = {
  "goFast": false,
  "prompt": "photo of evelyneabrahams full black burqa visible smile winking wearing glasses driving tehran 1980s colour looks straight into camera 20 years younger ",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "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

Evelyne's "Generate Image with Inpainting" action stands out as a powerful tool for developers looking to enhance their applications with dynamic image generation capabilities. By providing flexibility in image creation through prompts and masks, this action opens up a world of possibilities for creative projects, marketing initiatives, and more.

As you explore the potential of Evelyne, consider integrating this action into your workflows to streamline image generation, enhance user engagement, and unleash your creativity. The next step is to experiment with different prompts and masks to see how Evelyne can transform your visual content.