Create Stunning Images with Idnbeauty's Inpainting Action

In the ever-evolving world of digital design and content creation, the need for high-quality, customized images is paramount. Idnbeauty offers a powerful Cognitive Action that allows developers to generate images with remarkable precision, using advanced inpainting techniques. This action not only provides high-quality outputs but also caters to speed, making it an ideal solution for various applications. By leveraging customizable prompts, image dimensions, and model selection, developers can create stunning visuals that meet specific requirements effortlessly.
Use Cases
Imagine a scenario where a graphic designer needs to produce a series of promotional images for a fashion campaign. With Idnbeauty, they can generate tailored images that reflect the desired aesthetic, ensuring that each visual resonates with the target audience. Other use cases include creating unique artwork, enhancing product images for e-commerce, or generating personalized content for social media platforms. The versatility of this action makes it a valuable tool across industries, from marketing to entertainment.
Prerequisites
To get started with Idnbeauty’s Cognitive Action, you will need an API key and a basic understanding of API calls.
Generate Image with Inpainting and Style Guidance
This action generates images using an advanced image-to-image or inpainting mode. It leverages the 'dev' model for high-quality outputs and the 'schnell' model for faster processing. Developers can adjust dimensions, apply LoRA weights, and provide highly customized prompts to create images tailored to their needs.
Input Requirements: The input for this action requires a structured object with various properties, including:
- prompt: A descriptive text prompt that guides the image generation.
- image: (Optional) A URI for the input image used in image-to-image or inpainting mode.
- mask: (Optional) A URI for the image mask used in inpainting.
- model: Specifies which model to use, either 'dev' or 'schnell'.
- width and height: Define the dimensions of the generated image (effective only if aspect_ratio is set to 'custom').
- numOutputs: The number of images to generate, with a maximum of 4.
- aspectRatio: Defines the aspect ratio for the generated image.
- outputFormat: Specifies the desired file format for the output images (e.g., 'webp', 'jpg', 'png').
Expected Output: The action returns a generated image based on the provided inputs. For example, an output could be a direct link to the generated image, such as:
https://assets.cognitiveactions.com/invocations/7877a445-c40a-4e0a-998d-92356ceb6ea1/89e5276b-4406-4f2a-8591-60e24773c24f.png
Use Cases for this specific action:
- Fashion Promotion: Create visually compelling images for marketing campaigns that require specific themes or styles.
- E-commerce: Generate product images that highlight features and aesthetics tailored to customer preferences.
- Social Media Content: Produce unique visuals that stand out in crowded feeds, enhancing engagement and brand identity.
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 = "c3dd1b67-6a6d-4db9-b2c0-df37a6cfdaf4" # Action ID for: Generate Image with Inpainting and Style Guidance
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"model": "dev",
"goFast": false,
"prompt": "IDNBEAUTY A close-up portrait of a woman with traditional floral accessories in her hair and a statement necklace adorned with pearls and gems. Her soft makeup emphasizes her bold lips and expressive features. The background is a rich red, creating a dramatic contrast that enhances her elegance. The style is realistic photography with vibrant details, capturing the intricacies of the flowers, jewelry, and facial features, creating a sense of high-fashion elegance",
"loraScale": 0.94,
"megapixels": "1",
"numOutputs": 1,
"aspectRatio": "2:3",
"outputFormat": "png",
"guidanceScale": 2,
"outputQuality": 80,
"promptStrength": 0.61,
"numInferenceSteps": 28,
"additionalLoraScale": 0.22
}
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
Idnbeauty’s image generation action is a game-changer for developers looking to create high-quality, customized visuals quickly and efficiently. With its flexibility in input options, model selection, and output formats, this action caters to a wide range of use cases, from marketing to creative projects. Start integrating Idnbeauty into your projects today and unlock the potential of advanced image generation!