Create Stunning Images Effortlessly with Nastia's Inpainting Action

26 Apr 2025
Create Stunning Images Effortlessly with Nastia's Inpainting Action

In the world of digital content creation, visual appeal is paramount. Enter Nastia, a powerful service designed to enhance your creative projects through advanced image generation and inpainting capabilities. With Nastia’s Cognitive Actions, developers can effortlessly generate high-quality images tailored to specific needs, making it an invaluable tool for anyone looking to elevate their visual content. Whether you’re crafting marketing materials, designing social media posts, or enhancing product images, Nastia simplifies the process, saving you time while delivering exceptional results.

Imagine transforming a simple text prompt into a captivating visual. Nastia enables you to do just that, allowing for custom configurations that meet various project requirements. From controlling image aspect ratios to adjusting output quality, the flexibility offered by Nastia’s actions is unmatched. Use cases span from creating marketing visuals to generating unique artwork, ensuring that your content stands out in a crowded digital landscape.

Before diving into the specifics of the Cognitive Actions, be sure to secure your Cognitive Actions API key and familiarize yourself with general API call principles.

Generate Inpainted Image

The "Generate Inpainted Image" action is designed to create high-quality images through the processes of image inpainting and image-to-image transformation. This action solves the problem of generating visually appealing images from textual descriptions, effectively turning your ideas into reality. Whether you need a quick image for a blog post or a detailed graphic for a marketing campaign, this action provides the tools necessary to produce stunning visuals.

Input Requirements

To use this action, you will need to provide a structured input that includes the following key parameters:

  • prompt (required): A descriptive text prompt that guides the image generation.
  • mask: A URI pointing to an image mask for inpainting.
  • image: A URI for input images when using image-to-image translation.
  • width and height: Custom dimensions for your generated image, if needed.
  • additional parameters: Such as seed, loraStrength, inferenceModel, and others to refine your output.

Example input might look like this:

{
  "prompt": "NASTIA is sitting at an elegant Parisian café, sipping a cappuccino...",
  "loraStrength": 1,
  "denoisingSteps": 28,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "numberOfOutputs": 1,
  "approxMegapixels": "1",
  "imageAspectRatio": "3:4",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraStrength": 1,
  "diffusionGuidanceScale": 3,
  "inputPromptSensitivity": 0.8
}

Expected Output

The output will be a URI link to the generated image, available in various formats like webp, jpg, or png, depending on the specified parameters. For instance:

[
  "https://assets.cognitiveactions.com/invocations/4f957045-1c89-483e-a2f9-e555537a6a3e/924c9fd9-7466-45c6-9601-30a45d086b01.webp"
]

Use Cases for this Specific Action

  1. Marketing Materials: Create eye-catching visuals for advertisements or social media posts that resonate with your audience.
  2. Content Creation: Generate unique images for blog articles or website content, enhancing user engagement.
  3. Artistic Projects: Use text prompts to produce artwork or illustrations that align with specific themes or concepts.
  4. Prototyping: Quickly generate images for design mockups or presentations, facilitating feedback and iteration.
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 = "1e963851-3d29-40d8-a928-5a4b9cd959f9" # Action ID for: Generate Inpainted Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": " NASTIA  is sitting at an elegant Parisian café, sipping a cappuccino. NASTIA wears a fashionable dress, effortlessly capturing the essence of Parisian style. Her smartphone and a designer handbag rest on the table beside her, as she casually glances at her phone. The backdrop features classic Haussmann-style buildings, warm sunlight, and a bustling yet sophisticated atmosphere of people enjoying their day. The scene evokes a luxurious and aspirational aesthetic, perfect for social media.",
  "loraStrength": 1,
  "denoisingSteps": 28,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "numberOfOutputs": 1,
  "approxMegapixels": "1",
  "imageAspectRatio": "3:4",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraStrength": 1,
  "diffusionGuidanceScale": 3,
  "inputPromptSensitivity": 0.8
}

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

Nastia's "Generate Inpainted Image" action opens up a world of possibilities for developers and content creators alike. By leveraging advanced image generation techniques, you can streamline your creative processes and produce visually stunning results with minimal effort. Whether you're looking to enhance your marketing strategy or explore artistic endeavors, Nastia provides the tools you need to succeed. Start integrating these Cognitive Actions into your projects today and watch your visual content transform!