Create Stunning Images with Vee's Inpainting Action

In today's digital landscape, the demand for high-quality, customized images is ever-increasing. Vee offers developers a powerful Cognitive Action called "Generate Inpainted Image," which leverages advanced inpainting techniques to create stunning visuals tailored to specific needs. This action allows for a high degree of customization, enabling you to specify parameters like mask URIs, image formats, quality, and various adjustments to enhance the output. Whether you're looking for detailed imagery or quick results, Vee's inpainting capabilities simplify the process, saving you time while delivering professional-grade images.
Common use cases for this action include creating unique artwork, generating product images for e-commerce, enhancing marketing materials, or simply experimenting with creative concepts. With Vee, you can transform text prompts into visually captivating images that align perfectly with your vision.
Prerequisites
To get started with Vee's Cognitive Actions, you will need an API key and a basic understanding of making API calls.
Generate Inpainted Image
The "Generate Inpainted Image" action is designed to create images using inpainting techniques. This action excels in allowing developers to customize various aspects of image generation, making it suitable for both high-detail and rapid image production.
Purpose
This action addresses the need for personalized image creation by enabling users to input specific prompts and adjust parameters for quality and style. It is particularly useful in scenarios where stock images do not meet specific creative requirements.
Input Requirements
To use this action, you need to provide a JSON object with the following input properties:
- prompt (string): A detailed description of the desired image.
- mask (string): (Optional) A URI for an image mask for inpainting.
- image (string): (Optional) A base image for transformation.
- width (integer): (Optional) The width of the generated image (between 256 and 1440).
- height (integer): (Optional) The height of the generated image (between 256 and 1440).
- goFast (boolean): (Optional) Enables faster image generation.
- aspectRatio (string): (Optional) Defines the aspect ratio of the output image.
- numOutputs (integer): (Optional) Specifies how many images to generate (between 1 and 4).
- outputFormat (string): (Optional) Specifies the file format for the output images (e.g., webp, jpg, png).
- guidanceScale (number): (Optional) Controls the guidance scale during the generation process.
- outputQuality (integer): (Optional) Defines the quality level for output images (0 to 100).
- numInferenceSteps (integer): (Optional) Specifies the number of denoising steps (1 to 50).
Example Input:
{
"prompt": "The image shows vee relaxing on a beach under large beige umbrellas...",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 2,
"aspectRatio": "9:16",
"outputFormat": "png",
"guidanceScale": 2.5,
"outputQuality": 90,
"promptStrength": 0.8,
"numInferenceSteps": 28
}
Expected Output
The output will be an array of generated image URLs that correspond to the specifications provided in the input.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/2f780318-eb91-420c-bd93-c3b966ba1b10/20443d91-8fad-4b64-988a-12a5b87ca48c.png",
"https://assets.cognitiveactions.com/invocations/2f780318-eb91-420c-bd93-c3b966ba1b10/c595ff12-ca96-4415-8641-ddd2c6e78f0a.png"
]
Use Cases for this Action
- Art Creation: Artists can use this action to generate unique pieces based on detailed prompts, allowing for rapid prototyping of ideas.
- E-commerce: Businesses can create product images that highlight specific features or styles, enhancing their marketing efforts.
- Content Generation: Bloggers or content creators can produce custom images that fit their narratives, improving visual engagement.
- Creative Exploration: Developers can experiment with different prompts and parameters to discover new creative possibilities in their projects.
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 = "448a0133-0593-43d6-a02b-4d36ace77bc8" # 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": "The image shows vee relaxing on a beach under large beige umbrellas. She is wearing a white strapless swimsuit,which has a feminine and elegant touch to her beach look.\n\nShe accessorizes with small, rectangular black sunglasses, which give her a modern, chic vibe. Around her neck, she is wearing a delicate, shiny necklace, adding a hint of luxury to her outfit. Her hair is curly and shoulder length.\n\nThe camera angle in the image is from a close-up, low-angle perspective, capturing the woman reclining on a beach lounge chair. The camera appears to be held at arm's length as she takes a selfie. The angle slightly tilts upward, giving prominence to her face and upper body while also providing a glimpse of the beach and umbrellas in the background. This angle emphasizes her relaxed pose while including enough of the surrounding scene to set the context of a beach setting. The background shows a sandy beach with several lounge chairs, umbrellas, and a few people enjoying the day near the water. In the distance, there are green hills, suggesting the location could be a scenic coastal area. The overall ambiance feels calm and leisurely, with the woman embodying a relaxed, yet fashionable beach style.",
"loraScale": 1,
"modelType": "dev",
"numOutputs": 2,
"aspectRatio": "9:16",
"outputFormat": "png",
"guidanceScale": 2.5,
"outputQuality": 90,
"extraLoraScale": 1,
"promptStrength": 0.8,
"numInferenceSteps": 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
Vee's "Generate Inpainted Image" action offers developers a robust tool for creating high-quality, customized images quickly and efficiently. With its flexible input options and the ability to tailor outputs to specific needs, this action is ideal for a variety of applications, from marketing to artistic endeavors. Start integrating Vee into your projects today and unlock the potential of customized image generation!