Generate Custom Images with Inpainting Using Colinmcdonnell22/spoot Actions

In the world of image generation, the ability to create custom visuals that meet specific requirements can elevate applications to new heights. The colinmcdonnell22/spoot API provides powerful Cognitive Actions that allow developers to generate images with advanced inpainting features. This article will guide you through using the Generate Image with Inpainting action, detailing its capabilities, input requirements, output results, and how to seamlessly integrate it into your applications.
Prerequisites
Before you start using the Cognitive Actions, ensure you have the necessary API key for the Colin McDonnell 22 platform. Authentication typically involves passing this API key in the request headers, allowing you to securely access the available actions.
Cognitive Actions Overview
Generate Image with Inpainting
The Generate Image with Inpainting action enables you to create custom images using sophisticated inpainting techniques. You can leverage different models (dev or schnell) and customize various parameters such as dimensions, masks, image quality, and output format. The schnell model is optimized for speed, making it ideal for rapid image generation.
Input
The required input schema for this action is as follows:
- prompt (string, required): Describes the image to generate (e.g., "spoot character playing baseball").
- mask (string, optional): A URI for the image mask used in inpainting mode.
- seed (integer, optional): A random seed for reproducibility.
- image (string, optional): An input image for inpainting.
- width (integer, optional): The generated image's width (if using custom aspect ratio).
- height (integer, optional): The generated image's height (if using custom aspect ratio).
- mainLoraScale (number, optional): Determines the strength of the primary LoRA.
- enableFastMode (boolean, optional): Enables faster predictions.
- inferenceModel (string, default: "dev", optional): Selects the model for inference.
- promptStrength (number, default: 0.8, optional): Influences the relevance of the prompt.
- numberOfOutputs (integer, default: 1, optional): Number of image outputs to generate.
- imageAspectRatio (string, default: "1:1", optional): Specifies aspect ratio.
- imageOutputFormat (string, default: "webp", optional): Determines output format.
- imageOutputQuality (integer, default: 80, optional): Sets the quality of the output image.
Example Input:
{
"prompt": "spoot character playing baseball",
"mainLoraScale": 1.75,
"enableFastMode": true,
"inferenceModel": "schnell",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageAspectRatio": "1:1",
"imageOutputFormat": "png",
"imageOutputQuality": 80,
"additionalLoraScale": 1,
"guidanceScaleFactor": 5,
"totalInferenceSteps": 4,
"approximateMegapixels": "1"
}
Output
When the action is executed successfully, it returns a URL to the generated image. An example output would look like this:
[
"https://assets.cognitiveactions.com/invocations/8c087134-902f-4a71-abe6-9ee2c032564b/89232d4f-5ce1-4001-ad18-ff50adc13567.png"
]
Conceptual Usage Example (Python)
Here is a conceptual Python code snippet demonstrating how to call the Generate Image with Inpainting action:
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 = "f7e180dd-ad99-4446-b7c1-4d3061fa161d" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"prompt": "spoot character playing baseball",
"mainLoraScale": 1.75,
"enableFastMode": True,
"inferenceModel": "schnell",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageAspectRatio": "1:1",
"imageOutputFormat": "png",
"imageOutputQuality": 80,
"additionalLoraScale": 1,
"guidanceScaleFactor": 5,
"totalInferenceSteps": 4,
"approximateMegapixels": "1"
}
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, you replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and utilize the provided action ID. The input payload is structured according to the action’s requirements, ensuring a smooth execution of the request.
Conclusion
The Generate Image with Inpainting action from the colinmcdonnell22/spoot API offers developers robust capabilities for generating custom images tailored to specific needs. By using this action, you can easily create visually appealing content with various customization options. Consider exploring additional use cases and experiment with different parameters to maximize the potential of your applications!