Create Stunning Inpainted Images with Shakira's AI Actions

25 Apr 2025
Create Stunning Inpainted Images with Shakira's AI Actions

In the realm of digital creativity, the ability to generate and manipulate images has become increasingly accessible and efficient through advanced Cognitive Actions. The "Shakira" service offers a powerful action named "Create Inpainted Image" that allows developers to seamlessly generate inpainted images based on user-defined prompts. This action is particularly beneficial for those looking to enhance their creative projects, whether in marketing, entertainment, or digital art.

The primary advantage of using Shakira's inpainting capability lies in its speed and precision. Leveraging advanced models, developers can create stunning visuals that match specific requirements, such as size, quality, and artistic style. Common use cases include generating unique graphics for social media campaigns, creating concept art for games and animations, or even modifying existing images to fit a new narrative.

To get started, you'll need a Cognitive Actions API key and a basic understanding of making API calls. This will enable you to fully utilize the capabilities of the "Create Inpainted Image" action.

Create Inpainted Image

The "Create Inpainted Image" action is designed to generate images based on a provided prompt, allowing for creative freedom and customization. This action effectively addresses the challenge of producing high-quality visuals quickly, making it a valuable tool for developers in various fields.

Input Requirements

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

  • Prompt: A descriptive text that guides the image generation (e.g., "Studio shot of SHAKIRA dressed in SR shoes and Royal Blue scrubs holding a clipboard.").
  • Mask: (Optional) An image mask for inpainting mode.
  • Image: (Optional) An input image for image-to-image or inpainting mode.
  • Width & Height: (Optional) Specify dimensions if using a custom aspect ratio.
  • Aspect Ratio: Defines the image's proportions (e.g., "1:1", "16:9").
  • Fast Mode: (Optional) Enable for quicker predictions.
  • Guidance Scale: Adjust for the diffusion process.
  • Output Quality: Specify the quality level of the generated image.
  • Number of Outputs: Determine how many images to generate (1-4).
  • Inference Model: Choose the model for generation (options: "dev" or "schnell").

Expected Output

The action will return generated images in the specified format (e.g., webp, jpg, png). Each output will be a URL linking to the generated image files.

Use Cases for this Specific Action

  • Marketing and Advertising: Quickly generate visuals tailored for campaigns, enabling rapid iterations based on feedback.
  • Entertainment and Media: Create unique promotional images for movies, music, or events, enhancing audience engagement.
  • Digital Art and Design: Assist artists in visualizing concepts by generating reference images based on their ideas or prompts.
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 = "40fcdc4d-f8fd-4d06-8b09-af8592e7b7e7" # Action ID for: Create 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": "Studio shot of SHAKIRA dressed in SR shoes and Royal Blue scrubs holding a clipboard. ",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 100,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "primaryLoraScale": 1,
  "additionalLoraScale": 0.8,
  "additionalLoraWeights": "maffuw/scrub_runners",
  "numberOfInferenceSteps": 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

The "Create Inpainted Image" action within Shakira presents an exciting opportunity for developers to elevate their creative projects through AI-driven image generation. By harnessing this action, you can streamline your workflow, produce high-quality visuals, and explore new creative avenues. Whether you're working in marketing, entertainment, or digital art, the potential applications are vast and varied.

As a next step, consider experimenting with different prompts and image parameters to discover the full capabilities of this powerful action. Embrace the future of creativity with Shakira!