Create Stunning Images with Lauramdg's Inpainting Action

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

In the realm of digital content creation, the ability to generate high-quality images quickly and efficiently is invaluable. Lauramdg offers a powerful Cognitive Action that allows developers to generate images using inpainting techniques, enabling a new level of creativity and customization. This action supports adjustable parameters for aspect ratio, resolution, and guidance scale, making it a versatile tool for artists, marketers, and content creators alike.

With Lauramdg's image generation capabilities, you can easily produce images tailored to your specifications. Whether you're looking to enhance existing images or create entirely new ones from prompts, the inpainting action simplifies the process. Common use cases include generating unique visuals for social media, creating marketing materials, or even designing assets for games and apps. The speed and flexibility of this action make it a go-to solution for developers looking to elevate their projects.

Prerequisites

To get started with Lauramdg'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 empowers developers to create high-quality images by either inpainting existing images or generating images from scratch based on descriptive prompts. This action is particularly useful for users looking to manipulate specific areas of an image or generate entirely new visuals based on detailed descriptions.

Input Requirements

  • Prompt: A descriptive text that guides the image generation process (required).
  • Image: An input image for inpainting or image-to-image generation (optional).
  • Mask: An image mask specifically for inpainting mode (optional).
  • Width and Height: Dimensions of the generated image, applicable when using a custom aspect ratio (optional).
  • Output Format: The format for the generated image, such as webp, jpg, or png.
  • Output Count: Number of images to generate (1-4).
  • Output Quality: Quality of the output images, from 0 (lowest) to 100 (highest).
  • Inference Model: Choose between "dev" or "schnell" models for image generation.
  • Inference Steps: Number of steps for denoising; more steps yield more detailed images.
  • Prompt Strength: Determines how strongly the prompt influences the generated image.
  • Guidance Scale: Controls how closely the image adheres to the prompt.

For example, a developer might send the following input:

{
  "image": "https://replicate.delivery/pbxt/LsXH96yXuMQutuHdDa8zlPohfGe9vMd16okB8TjBTlXqe2Iz/Screenshot_20241029_123657_Instagram.jpg",
  "prompt": "LauraMDG A beautiful brunette with long hairs, busty girl taking a selfie with an iphone 12 pro",
  "imageFormat": "jpg",
  "outputCount": 1,
  "outputQuality": 90,
  "inferenceModel": "dev",
  "inferenceSteps": 28,
  "promptStrength": 0.46,
  "imageAspectRatio": "1:1",
  "mainLoraStrength": 0.89,
  "additionalLoraStrength": 1,
  "diffusionGuidanceScale": 3.5
}

Expected Output

The action will return a high-quality image generated based on the provided prompt and parameters. An example output URL might look like this:

https://assets.cognitiveactions.com/invocations/7a5a553b-aec9-4c53-aa19-88c2eb5a0405/cecd6164-1e58-4b7a-9b56-04fe640e5bfe.jpg

Use Cases for this Specific Action

  • Artistic Creation: Artists can use this action to generate unique artwork based on their descriptions or modify existing pieces.
  • Marketing Content: Marketers can create stunning visuals for campaigns, social media posts, or website graphics without needing extensive graphic design skills.
  • Game Development: Developers can generate character designs or environmental assets based on prompts, speeding up the game design process.
  • Personal Projects: Individuals looking to create customized images for personal use, such as gifts or social media profiles, can easily do so with this action.
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 = "18b9455c-bc39-4c17-8684-63a56e73ae23" # 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 = {
  "image": "https://replicate.delivery/pbxt/LsXH96yXuMQutuHdDa8zlPohfGe9vMd16okB8TjBTlXqe2Iz/Screenshot_20241029_123657_Instagram.jpg",
  "prompt": "LauraMDG A beautiful brunette with long hairs, busty girl taking a selfie with an iphone 12 pro ",
  "imageFormat": "jpg",
  "outputCount": 1,
  "outputQuality": 90,
  "inferenceModel": "dev",
  "inferenceSteps": 28,
  "promptStrength": 0.46,
  "imageAspectRatio": "1:1",
  "mainLoraStrength": 0.89,
  "additionalLoraStrength": 1,
  "diffusionGuidanceScale": 3.5
}

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

Lauramdg's "Generate Image with Inpainting" action offers a powerful and flexible solution for developers looking to enhance their projects with high-quality image generation. Whether you're creating content for marketing, art, or personal projects, this action simplifies the process and allows for a high degree of customization. With the ability to adjust parameters and generate images quickly, Lauramdg empowers you to unleash your creativity and bring your ideas to life.

Explore the possibilities of image generation today and see how Lauramdg can elevate your work!