Create Stunning Images with Inpainting Using the zeg06/sisco Cognitive Actions

In the realm of image generation, the zeg06/sisco API provides powerful Cognitive Actions that empower developers to create visually stunning images with unique capabilities. Among these is the action for generating images with inpainting, which allows for detailed image-to-image transformations based on descriptive prompts. With customizable settings for output quality, aspect ratio, and more, developers can harness the potential of this API to enrich their applications.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for the zeg06/sisco platform to authenticate your requests.
- Familiarity with making HTTP requests and handling JSON data.
To authenticate your requests, you will typically pass your API key in the headers of your HTTP requests.
Cognitive Actions Overview
Generate Image with Inpainting
The Generate Image with Inpainting action allows users to create images by transforming existing ones using detailed prompts. This action is particularly useful for projects requiring image modifications or enhancements.
Input
The input to this action consists of various fields that influence the image generation process. Here’s how the input schema looks:
{
"prompt": "Describe the image you want to generate.",
"image": "https://example.com/path/to/image.png",
"goFast": false,
"imageFormat": "jpg",
"outputCount": 1,
"imageQuality": 100,
"inferenceModel": "dev",
"imageMegapixels": "1",
"loraWeightScale": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "9:16",
"inferenceStepCount": 50,
"additionalLoraScale": 1,
"diffusionGuidanceScale": 3
}
- Required Fields:
prompt(string): A detailed description of the desired image.
- Optional Fields:
image(string): URI for the input image to be transformed.goFast(boolean): A flag to enable faster processing.imageFormat(string): Defines the output image format (webp, jpg, png).outputCount(integer): Number of images to generate (1 to 4).imageQuality(integer): Quality level of the output image (0 to 100).inferenceModel(string): Specifies the model version for inference.imageMegapixels(string): Specifies the total megapixels of the generated image.loraWeightScale(number): Adjusts the strength of the main LoRA application.promptIntensity(number): Strength of the prompt in image transformation.imageAspectRatio(string): Defines the aspect ratio of the generated image.inferenceStepCount(integer): Number of denoising steps to perform.additionalLoraScale(number): Strength of additional LoRA weights.diffusionGuidanceScale(number): Guidance scale for the diffusion process.
Example Input
For instance, a typical input JSON payload for this action could look like this:
{
"image": "https://replicate.delivery/pbxt/MEwgfdgAvfuSriNvOO9wI0CyyxRd5yudh2ugAfhDbGUVDuzu/45a42edc-8e28-4380-be44-0bf00a23823a.png",
"goFast": false,
"prompt": "Ultra-realistic photo of sisco portrayed as Robin, a Filipino character, wearing his iconic red and green suit with a yellow cape and black mask, capturing his role as the youthful hero.",
"imageFormat": "jpg",
"outputCount": 1,
"imageQuality": 100,
"inferenceModel": "dev",
"imageMegapixels": "1",
"loraWeightScale": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "9:16",
"inferenceStepCount": 50,
"additionalLoraScale": 1,
"diffusionGuidanceScale": 3
}
Output
When executed, this action typically returns a list of URLs pointing to the generated images. For example:
[
"https://assets.cognitiveactions.com/invocations/5c7890d6-7bea-4086-82c8-2c369b6fa954/e0fa5fb9-b828-4b32-ae1f-39e1227dc75c.jpg"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Image with 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 = "9da18810-2b3e-4c2e-874d-3780af81d7ac" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"image": "https://replicate.delivery/pbxt/MEwgfdgAvfuSriNvOO9wI0CyyxRd5yudh2ugAfhDbGUVDuzu/45a42edc-8e28-4380-be44-0bf00a23823a.png",
"goFast": False,
"prompt": "Ultra-realistic photo of sisco portrayed as Robin, a Filipino character, wearing his iconic red and green suit with a yellow cape and black mask, capturing his role as the youthful hero.",
"imageFormat": "jpg",
"outputCount": 1,
"imageQuality": 100,
"inferenceModel": "dev",
"imageMegapixels": "1",
"loraWeightScale": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "9:16",
"inferenceStepCount": 50,
"additionalLoraScale": 1,
"diffusionGuidanceScale": 3
}
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, you replace the COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual API key and endpoint. The payload is structured according to the input schema, allowing for a seamless execution of the action.
Conclusion
The zeg06/sisco Cognitive Actions, particularly the Generate Image with Inpainting, provide developers with a robust tool for creating and manipulating images programmatically. With the ability to customize various parameters, developers can achieve impressive results tailored to their specific needs. Consider exploring additional use cases, integrating this action into creative applications, or experimenting with different settings to unlock its full potential.