Create Stunning Inpainted Images with Qajartest1

In today’s digital landscape, the ability to generate and manipulate images efficiently is vital for developers across various industries. Qajartest1 offers powerful Cognitive Actions designed for image generation, particularly focusing on inpainting capabilities. This service allows developers to create inpainted images from existing images and masks, enabling them to fill in missing or damaged areas while preserving the original content. The benefits of using Qajartest1 include enhanced creativity, speed, and flexibility in image creation, making it an invaluable tool for artists, designers, and developers alike.
Common use cases for Qajartest1 include creating artworks, enhancing visual content for marketing campaigns, or even restoring old photographs. Developers can utilize this service to automate the creation of unique images based on specific prompts, transforming their concepts into reality with minimal effort.
Before diving into the functionalities, ensure you have your Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Inpainted Image with Mask
The "Generate Inpainted Image with Mask" action is designed to create a new image by inpainting over specified areas of an input image based on a provided mask. This action solves the problem of missing sections in images, allowing developers to seamlessly fill in gaps while maintaining the overall aesthetic and context of the original image.
Input Requirements
To use this action, you will need to provide:
- Image: URI of the input image for inpainting.
- Mask: URI of the mask image where white areas will be inpainted and black areas will be preserved.
- Prompt: Descriptive text that guides the AI on how to generate the output image.
- Width and Height: Dimensions of the output image in pixels (default is 1024x1024).
- Num Outputs: Number of images to generate (between 1 and 4).
- Additional parameters like Guidance Scale, Prompt Strength, and Refine Style can be configured to fine-tune the output.
Expected Output
The expected output is a generated image based on the input image and mask, along with the specified parameters. The output will be a URI linking to the newly created inpainted image.
Use Cases for this Specific Action
- Art Creation: Artists can use this action to fill in missing areas of their artwork or create variations of existing pieces.
- Photo Restoration: Developers working with historical images can restore parts of photographs that have been damaged or lost.
- Marketing Material: Marketers can create custom visuals that fit their branding or campaign needs by inpainting specific sections of images to highlight products or services.
```python
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 = "df7afbb7-b88f-4ce5-a3fd-7a7dec092be1" # Action ID for: Generate Inpainted Image with Mask
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"width": 1024,
"height": 1024,
"prompt": "oil painting of TOK a multifaceted Iranian woman from TOK who embodies the essence of past, present, and future. She should have the boldness and independence of Gen 4, with dark hair featuring modern embellishments like piercings and tattoos. Her style should be a tusion of traditional Iranian beauty and contemporary global fashion trends, wearing popular brands like cara. This woman should also display elements or tuturistic beauty standards, such as cosmetic enhancements, symbolizing the evolving ideals of femininity and freedom.\nHer overall appearance should convey a blend of power, determination, intellectual depth,\nand a touch or melancholy, retlecting a spirit that Is both resilient and elegantly aignitied.\nThis character represents not just the aspirations and visions of modern Iranian women but\nalso their rich and complex heritage sin style of lOK",
"loraScale": 0.6,
"numOutputs": 1,
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"highNoiseFrac": 0.8,
"applyWatermark": true,
"negativePrompt": "European look , Indian, hijab, scart, detormed, worst quality, text, watermark, logo, banner,\nextra digits, deformed fingers, deformed hands, cropped, jpeg artefacts, signature, username, error, sketch, duplicate, ualy, monochrome, horror, geometry. mutation,",
"promptStrength": 0.8,
"schedulingMethod": "K_EULER",
"numInferenceSteps": 50
}
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 Qajartest1 service provides developers with robust tools for image generation and inpainting, allowing for creative expression and practical applications across various fields. By leveraging the "Generate Inpainted Image with Mask" action, you can automate the creation of stunning visuals tailored to your specific needs. As the demand for unique and engaging digital content continues to rise, integrating Qajartest1 into your projects can significantly enhance your workflow and output quality. Explore the possibilities and take your image generation capabilities to the next level!