Transform Your Images with My Photo Face Inpainting Actions

25 Apr 2025
Transform Your Images with My Photo Face Inpainting Actions

In today's digital landscape, visual content plays a crucial role in communication and branding. "My Photo Face" offers an advanced Cognitive Action called "Generate Image Inpainting" that empowers developers to enhance and transform images effortlessly. This action allows you to perform image inpainting and transformation, enabling you to create stunning visuals tailored to your specific needs. Whether you are working on a marketing campaign, social media content, or any project requiring high-quality images, this tool can significantly speed up your workflow while simplifying the creative process.

Imagine the possibilities: you can replace unwanted objects in an image, fill in missing areas, or even create entirely new scenes based on your prompts. With customizable parameters such as model type, guidance scale, and output formats, you have the flexibility to achieve the desired result, whether that's detailed rendering or faster outputs.

Prerequisites

Before diving into the integration of "My Photo Face," ensure you have a Cognitive Actions API key and a basic understanding of making API calls.

Generate Image Inpainting

The "Generate Image Inpainting" action is designed to help you modify images by filling in or transforming specific areas based on provided inputs. This action is particularly useful for developers looking to automate image editing tasks or enhance visual storytelling.

Purpose

This action solves the problem of manual image editing by automating the process of inpainting, allowing for quick adjustments and creative modifications without the need for complex software.

Input Requirements

To utilize this action, you'll need to provide a structured input including:

  • Prompt: A detailed description of the desired image.
  • Image: The URI of the input image.
  • Mask: An optional image mask for precise inpainting.
  • Model: Choose between 'dev' for detailed outputs or 'schnell' for quick results.
  • Aspect Ratio: Specify the desired aspect ratio for the output image.
  • Additional parameters like width, height, number of outputs, and guidance scale can also be defined.

Example Input:

{
  "model": "dev",
  "prompt": "A realistic facing photo of jayton as a professional in a bright office...",
  "numOutputs": 4,
  "aspectRatio": "16:9",
  "outputFormat": "png",
  "guidanceScale": 2.2,
  "outputQuality": 100,
  "promptStrength": 0.8,
  "loraStrengthScale": 1,
  "numInferenceSteps": 32,
  "additionalLoraStrengthScale": 1
}

Expected Output

The output will consist of multiple image URIs based on your specified parameters. The generated images will reflect the transformations described in your prompt.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/.../image1.png",
  "https://assets.cognitiveactions.com/invocations/.../image2.png",
  "https://assets.cognitiveactions.com/invocations/.../image3.png",
  "https://assets.cognitiveactions.com/invocations/.../image4.png"
]

Use Cases for this Action

  • Marketing and Advertising: Quickly create promotional images by modifying existing visuals to better align with campaign themes.
  • Content Creation: Enhance blog posts or social media posts with custom images that capture the essence of your message.
  • Product Design: Visualize product concepts by altering images to include new designs or features.
  • Personal Projects: Bring your creative ideas to life by generating unique images based on your vision.
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 = "84354f30-9f53-4f76-ae8c-ac9b1bb787d2" # Action ID for: Generate Image 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",
  "prompt": "A realistic facing photo of jayton as a professional in a bright office in front of people presenting about AI and Automation upportunities. The audience, are entrepreneurs with different genders, and ethnicity, watches attentively, with expressions of interest and curiosity towards jayton. The room is a bright open glass office space. The photo is capturing the energy and excitement of business owners.",
  "numOutputs": 4,
  "aspectRatio": "16:9",
  "outputFormat": "png",
  "guidanceScale": 2.2,
  "outputQuality": 100,
  "promptStrength": 0.8,
  "loraStrengthScale": 1,
  "numInferenceSteps": 32,
  "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

"My Photo Face" offers powerful Cognitive Actions that simplify the image editing process, making it accessible for developers working on various projects. With the ability to generate custom images through inpainting, you can enhance visual content efficiently and creatively.

As you explore these capabilities, consider how you can integrate this action into your workflows to boost productivity and elevate your projects. Start experimenting today and unlock the full potential of your images!