Create Stunning Images with the priscilakorgut/pri Cognitive Actions

In the world of image generation, the priscilakorgut/pri API offers powerful Cognitive Actions that allow developers to create and enhance images with remarkable precision. Among the featured actions is the ability to generate images using custom inpainting techniques, which can be tailored to your specific artistic or functional requirements. By leveraging these pre-built actions, developers can save time and effort while achieving stunning visual results in their applications.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following prerequisites in place:
- API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform. This key should be included in the headers of your requests.
- Development Environment: Set up your development environment with Python and the
requestslibrary to easily make HTTP requests to the API.
Authentication Concept
Typically, authentication with the API is achieved by passing your API key in the request headers, which allows you to securely access the Cognitive Actions.
Cognitive Actions Overview
Generate Image with Custom Inpainting
Description: This action allows you to create and enhance images using prompts tailored for custom inpainting tasks. You have the ability to adjust various parameters, including width, height, image quality, and guidance scale, enabling precise control over the output. You can choose between the 'dev' model for detailed generation or the 'schnell' model for faster results.
- Category: Image Generation
Input
The input for this action requires a structured JSON object. Here's a breakdown of the required and optional fields:
- Required Fields:
prompt: A descriptive text prompt for image generation, which enhances the model's output quality.
- Optional Fields:
mask: URI of the image mask for inpainting (overrides width and height).image: URI of the input image for transformation (overwrites width and height).width: Output image width (256 to 1440).height: Output image height (256 to 1440).goFast: Boolean to enable faster generation (default is false).seed: Seed for randomness.numOutputs: Number of images to generate (1 to 4).imageFormat: Format of the output image (options: webp, jpg, png).guidanceScale: Strength of guidance during diffusion (suggested range 2 to 3.5).outputQuality: Quality of the output image (0 to 100).extraLora,loraScale,extraLoraScale: Parameters for additional LoRA weights.inferenceModel: Choose between 'dev' or 'schnell' for the inference model.promptStrength: Degree of alteration during image processing.imageAspectRatio: Aspect ratio for the output image.numInferenceSteps: Steps during the denoising process.disableSafetyChecker: Option to disable safety checks on generated images.
Example Input:
{
"image": "https://replicate.delivery/pbxt/Mi79Y0Gf0c60W8tonxHnwsLa6MFYgx9IfZ6CCNoQpq7YYDAu/6d1ed0448523964699c272e5fd0ea879.jpg",
"goFast": false,
"prompt": "TOK\"Uma mulher jovem e sofisticada com pele natural e maquiagem elegante, incluindo olhos esfumados e lábios nude brilhantes. ela esta com a boca fechada, nao aparece seus dentes na foto, Ela tem cabelos escuros e lisos, e veste um suéter preto de gola alta, transmitindo uma aura de confiança e poder. Seu olhar é intenso e cativante, e ela usa pequenos brincos dourados e um anel discreto. O fundo é completamente preto, criando um contraste dramático e um visual minimalista. A iluminação é suave e bem distribuída, destacando os contornos do rosto de forma natural.\"",
"loraScale": 1,
"numOutputs": 1,
"imageFormat": "jpg",
"guidanceScale": 3,
"outputQuality": 80,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageMegapixels": "1",
"imageAspectRatio": "1:1",
"numInferenceSteps": 28
}
Output
The action will return a JSON array containing the URLs of the generated images.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/da199417-a691-4bfb-9ed9-5cc19ad3a036/e522f5e2-57c7-4393-8d42-4dab9e195a50.jpg"
]
Conceptual Usage Example (Python)
Here's a conceptual Python code snippet demonstrating how to call this 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 = "84d0c577-682a-4e18-9e60-06d98f9c9065" # Action ID for Generate Image with Custom Inpainting
# Construct the input payload based on the action's requirements
payload = {
"image": "https://replicate.delivery/pbxt/Mi79Y0Gf0c60W8tonxHnwsLa6MFYgx9IfZ6CCNoQpq7YYDAu/6d1ed0448523964699c272e5fd0ea879.jpg",
"goFast": False,
"prompt": "TOK\"Uma mulher jovem e sofisticada com pele natural e maquiagem elegante...",
"loraScale": 1,
"numOutputs": 1,
"imageFormat": "jpg",
"guidanceScale": 3,
"outputQuality": 80,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageMegapixels": "1",
"imageAspectRatio": "1:1",
"numInferenceSteps": 28
}
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 example, replace the COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable contains the structured input for the action, and the request will send this to the API for processing.
Conclusion
The priscilakorgut/pri Cognitive Actions provide developers with a robust toolkit for generating and enhancing images. By utilizing the Generate Image with Custom Inpainting action, you can easily create stunning visuals tailored to your specifications. Whether you're building applications for art, design, or any other visual media, these Cognitive Actions can enhance your workflow and output quality. Start experimenting with these powerful capabilities today!