Enhance Your Applications with Custom Image Generation Using fovkotov/poor-01 Cognitive Actions

Integrating advanced image generation capabilities into your applications has never been easier with the fovkotov/poor-01 Cognitive Actions. This set of actions allows developers to create stunning custom images through a variety of inputs, including text prompts, image masks, and advanced settings for inpainting and aspect ratios. By leveraging these pre-built actions, you can enhance your applications with powerful image generation features without the need for extensive machine learning expertise.
Prerequisites
Before you start using the fovkotov/poor-01 Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform, which you will use for authentication.
- Familiarity with JSON format, as inputs and outputs will be structured in JSON.
- Basic knowledge of making HTTP requests, particularly in Python.
For authentication, you'll typically pass your API key in the headers of your requests.
Cognitive Actions Overview
Generate Custom Image with Mask and Inpainting
The Generate Custom Image with Mask and Inpainting action allows you to create custom images using input images and masks. It provides options for image inpainting, aspect ratio adjustments, and output quality settings, utilizing both dev and schnell models for varying inference speeds.
Input
The input to this action requires the following fields:
- prompt (required): A guiding text for image generation (e.g., "lake in style of poor,").
- mask (optional): URI of the image mask for inpainting.
- image (optional): URI of the input image for image-to-image or inpainting mode.
- width (optional): Specifies the width of the generated image (256 to 1440).
- height (optional): Specifies the height of the generated image (256 to 1440).
- loraScale (optional): Scale for the main LoRA application.
- denoisingSteps (optional): Number of denoising steps (1 to 50).
- enableFastMode (optional): Enables a faster prediction mode.
- inferenceModel (optional): Model selection for inference ("dev" or "schnell").
- numberOfOutputs (optional): Number of images to generate (1 to 4).
- imageAspectRatio (optional): Defines the aspect ratio for the output image.
- imageOutputFormat (optional): Chooses the output image format (e.g., "webp", "jpg", "png").
- imageOutputQuality (optional): Adjusts image quality from 0 to 100.
Here’s an example of the input JSON payload:
{
"prompt": "lake in style of poor, ",
"loraScale": 2.2,
"denoisingSteps": 28,
"enableFastMode": false,
"inferenceModel": "dev",
"numberOfOutputs": 2,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 80
}
Output
The action typically returns an array of generated image URIs. For example:
[
"https://assets.cognitiveactions.com/invocations/a7222276-e38b-4217-b577-1b96dbbd2530/edac5f00-3ecb-4968-9917-2936354dcfff.webp",
"https://assets.cognitiveactions.com/invocations/a7222276-e38b-4217-b577-1b96dbbd2530/f51bbaab-a227-443c-b48a-b3d65bbde1f3.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Custom Image with Mask and Inpainting 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 = "452ecfea-95d7-4e91-85e9-e841f553f7c3" # Action ID for Generate Custom Image with Mask and Inpainting
# Construct the input payload based on the action's requirements
payload = {
"prompt": "lake in style of poor, ",
"loraScale": 2.2,
"denoisingSteps": 28,
"enableFastMode": False,
"inferenceModel": "dev",
"numberOfOutputs": 2,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 80
}
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. The payload is structured according to the input schema, and the response is processed to print the output or any error messages.
Conclusion
The fovkotov/poor-01 Cognitive Actions provide developers with robust tools for integrating advanced image generation features into their applications. With capabilities like customizable prompts, image masks, and quality settings, you can create unique visual content tailored to your needs. Explore further use cases and experiment with different parameters to fully leverage the power of these actions in your projects!