Enhance Your Images with the Generate Inpainted Image Action from GoWaterBottle

In the realm of image processing, the ability to generate inpainted images opens up a world of creative possibilities. The GoWaterBottle specification provides developers with a powerful Cognitive Action called Generate Inpainted Image. This action allows for the generation of inpainted images from an input image, using customizable parameters to enhance the output quality. By leveraging this action, developers can create stunning visuals tailored to their specific needs.
Prerequisites
To use the Generate Inpainted Image action, you'll need to have access to the GoWaterBottle Cognitive Actions platform. This typically involves obtaining an API key, which you will include in your request headers for authentication.
Conceptually, authentication will look something like this: when making API calls, you'll pass your API key in the headers to ensure secure access to the service.
Cognitive Actions Overview
Generate Inpainted Image
The Generate Inpainted Image action creates an inpainted image based on an input image and a specified mask. This allows developers to modify images creatively by defining areas to be altered or preserved. The action supports various parameters that influence the output, such as seed values, dimensions, and refinement styles.
Input
The input for this action is structured as follows:
- mask (string, required): URI of the input mask for inpainting mode. Black areas remain unchanged; white areas will be inpainted.
- seed (integer, optional): Seed for random number generation. If left blank, a random seed is generated.
- image (string, required): URI of the input image for inpainting.
- width (integer, optional): The output image width in pixels (default: 1024).
- height (integer, optional): The output image height in pixels (default: 1024).
- prompt (string, optional): Textual prompt to guide image generation (default: "An astronaut riding a rainbow unicorn").
- refine (string, optional): Refinement style to apply (default: "no_refiner").
- loraScale (number, optional): Scale for LoRA (default: 0.6).
- scheduler (string, optional): Denoising scheduler to use (default: "K_EULER").
- guidanceScale (number, optional): Guidance scale for classifier-free guidance (default: 7.5).
- applyWatermark (boolean, optional): Whether to apply a watermark (default: true).
- inferenceSteps (integer, optional): Number of denoising steps (default: 50).
- negativePrompt (string, optional): Prompt for undesired image features.
- promptStrength (number, optional): Strength influence of the prompt (default: 0.8).
- numberOfOutputs (integer, optional): Number of images to generate (default: 1).
- highNoiseFraction (number, optional): Fraction of noise for expert ensemble refinement (default: 0.8).
- disableSafetyChecker (boolean, optional): Disable safety checker (default: false).
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "A photo of TOK water bottle, in a busy coffee shop",
"refine": "no_refiner",
"loraScale": 0.6,
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"applyWatermark": true,
"inferenceSteps": 50,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8
}
Output
The output of this action will typically be a URL pointing to the generated inpainted image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/33e72f3b-ac17-44fb-a5ef-2c23155b3a15/5e68a3e7-d4e2-4cb2-bf06-ffb7da69bfac.png"
]
Conceptual Usage Example (Python)
Here’s how a developer might call the Generate Inpainted Image action using Python:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "748ce900-150a-44d5-a660-5203da404dd8" # Action ID for Generate Inpainted Image
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "A photo of TOK water bottle, in a busy coffee shop",
"refine": "no_refiner",
"loraScale": 0.6,
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"applyWatermark": True,
"inferenceSteps": 50,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
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: {e.response.text}")
In this code snippet, replace the placeholders with your actual API key and endpoint. The action_id is set to the ID of the Generate Inpainted Image action. The payload is constructed based on the required input schema, ensuring all necessary fields are included.
Conclusion
The Generate Inpainted Image action from the GoWaterBottle specification provides developers with a powerful tool for image enhancement. By leveraging customizable parameters, you can create high-quality images tailored to your specific requirements. Consider exploring additional use cases or integrating this action into your applications to unlock new creative possibilities!