Generate Custom Images with Inpainting using dalykthemc/newface Actions

24 Apr 2025
Generate Custom Images with Inpainting using dalykthemc/newface Actions

In the world of image generation, the dalykthemc/newface API offers powerful Cognitive Actions that can transform your creative projects. One of the standout capabilities is generating custom images with inpainting using advanced models. This enables developers to create unique, visually appealing images by adjusting various parameters, ensuring that the final results align perfectly with their creative vision.

Prerequisites

Before you dive into integrating the dalykthemc/newface Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic familiarity with JSON and making HTTP requests.
  • A Python environment set up with the requests library for making API calls.

Authentication typically involves passing your API key in the headers of your requests, enabling secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate Custom Images with Inpainting

Description: This action allows you to generate custom images through an image-to-image process, utilizing inpainting capabilities. By selecting models optimized for either speed or optimal inference, you can fine-tune the output by adjusting parameters like guidance scale, aspect ratio, and more.

Category: Image Generation

Input

The input for this action is structured as follows:

{
  "prompt": "string",  // Required
  "mask": "string",    // Optional, URI for image mask
  "seed": "integer",   // Optional, for reproducible results
  "image": "string",   // Optional, URI for input image
  "model": "string",    // Optional, default is "dev"
  "width": "integer",   // Optional, for custom width
  "height": "integer",  // Optional, for custom height
  "loraScale": "number", // Optional, default is 1
  "megapixels": "string", // Optional, default is "1"
  "aspectRatio": "string", // Optional, default is "1:1"
  "guidanceScale": "number", // Optional, default is 3
  "enableFastMode": "boolean", // Optional, default is false
  "promptStrength": "number", // Optional, default is 0.8
  "numberOfOutputs": "integer", // Optional, default is 1
  "imageOutputFormat": "string", // Optional, default is "webp"
  "imageOutputQuality": "integer", // Optional, default is 80
  "additionalLoraScale": "number", // Optional, default is 1
  "numberOfInferenceSteps": "integer" // Optional, default is 28
}

Example Input:

{
  "model": "dev",
  "prompt": "JibitBoy, handsome, young, beautiful healthy eyes, healthy face, athletic body type, bLACK Burberry jacket, jeans, winter scenery, sitting at a fancy beautiful café near a glass window, photorealistic, street photography.",
  "loraScale": 1,
  "aspectRatio": "1:1",
  "guidanceScale": 3.5,
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "imageOutputFormat": "webp",
  "imageOutputQuality": 90,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Output

The output of this action typically consists of an array of URLs pointing to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/050441d8-32c0-4af3-9154-16491bb58d11/5686304e-447d-492e-a965-a30bf66ab775.webp",
  "https://assets.cognitiveactions.com/invocations/050441d8-32c0-4af3-9154-16491bb58d11/6b82fdde-99a1-47cc-bd84-95d36771df7f.webp",
  "https://assets.cognitiveactions.com/invocations/050441d8-32c0-4af3-9154-16491bb58d11/02b0725e-52e2-4015-8ae7-2907bba77111.webp",
  "https://assets.cognitiveactions.com/invocations/050441d8-32c0-4af3-9154-16491bb58d11/fa772be3-59f4-42f1-a5ec-e8533b92736e.webp"
]

Conceptual Usage Example (Python)

Here’s how you might invoke the Generate Custom Images with Inpainting 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 = "4d7afffe-d121-471e-b5d6-0625c91c5df6"  # Action ID for Generate Custom Images with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "JibitBoy, handsome, young, beautiful healthy eyes, healthy face, athletic body type, bLACK Burberry jacket, jeans, winter scenery, sitting at a fancy beautiful café near a glass window, photorealistic, street photography.",
    "loraScale": 1,
    "aspectRatio": "1:1",
    "guidanceScale": 3.5,
    "promptStrength": 0.8,
    "numberOfOutputs": 4,
    "imageOutputFormat": "webp",
    "imageOutputQuality": 90,
    "additionalLoraScale": 1,
    "numberOfInferenceSteps": 28
}

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 Python snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id is set for the image generation action, and the payload is structured according to the action's input schema. The response will provide the generated image URLs.

Conclusion

The dalykthemc/newface Cognitive Actions facilitate the creation of custom images with exceptional flexibility. By leveraging inpainting capabilities alongside various adjustable parameters, developers can produce high-quality, personalized imagery tailored to their specific needs. As you explore these actions, consider the diverse use cases, from creative projects to automated content generation, and integrate them into your applications for a transformative image generation experience.