Generate Stunning Images with Cognitive Actions from gastonmiguelartillo/labelspngss2

23 Apr 2025
Generate Stunning Images with Cognitive Actions from gastonmiguelartillo/labelspngss2

In today’s digital landscape, the demand for unique and visually appealing images is at an all-time high. The gastonmiguelartillo/labelspngss2 spec introduces powerful Cognitive Actions designed to generate images with advanced capabilities such as inpainting and LoRA adjustments. These pre-built actions allow developers to easily integrate sophisticated image generation features into their applications, enabling the creation of detailed and tailored visuals based on text prompts.

Prerequisites

Before diving into the Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of JSON structures and API requests.
  • Familiarity with a programming language such as Python for implementing the API calls.

Authentication typically involves including your API key in the request headers, allowing secure access to the action functionalities.

Cognitive Actions Overview

Generate Image with Inpainting and LoRA Adjustments

This action is designed for generating detailed images using a prediction model that combines inpainting capabilities with LoRA adjustments for personalized styling. It offers flexibility in output format, image size, quality, and the choice between fast and detailed generation modes.

Input

The action requires a structured JSON input. Here’s a breakdown of the required and optional fields:

  • prompt (required): A text prompt guiding the image generation.
  • mask (optional): URI of the image mask for inpainting mode.
  • seed (optional): Random seed for reproducible results.
  • image (optional): URI of an input image for image-to-image or inpainting mode.
  • width (optional): Width of the generated image (256 to 1440).
  • height (optional): Height of the generated image (256 to 1440).
  • outputCount (optional): Number of images to generate (1 to 4).
  • selectedModel (optional): Choose between "dev" and "schnell" for inference models.
  • denoisingSteps (optional): Number of steps for denoising (1 to 50).
  • imageAspectRatio (optional): Aspect ratio for the image.
  • imageOutputFormat (optional): Output file format (webp, jpg, png).
  • imageOutputQuality (optional): Quality of the output image (0 to 100).
  • Additional parameters for LoRA adjustments and optimization settings.

Example Input:

{
  "prompt": "with the same style of your training develope a new label that inncude many fruits ",
  "outputCount": 1,
  "selectedModel": "dev",
  "denoisingSteps": 28,
  "approxMegapixels": "1",
  "imageAspectRatio": "3:2",
  "mainLoraStrength": 1,
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "img2imgPromptStrength": 0.8,
  "additionalLoraStrength": 1,
  "diffusionGuidanceScale": 3,
  "enableSpeedOptimization": false
}

Output

The action returns a URL to the generated image. Here’s an example of the output structure:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/9360fba6-e515-4fd6-9d74-2b45f628a344/d167822c-dd43-475b-9477-a21c96afc96c.webp"
]

This output provides the link to the generated image, which can then be used or displayed in your application.

Conceptual Usage Example (Python)

Here’s how a developer might invoke this 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 = "a65f8715-34d7-445e-ba0c-3e808c7b467b" # Action ID for Generate Image with Inpainting and LoRA Adjustments

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "with the same style of your training develope a new label that inncude many fruits ",
    "outputCount": 1,
    "selectedModel": "dev",
    "denoisingSteps": 28,
    "approxMegapixels": "1",
    "imageAspectRatio": "3:2",
    "mainLoraStrength": 1,
    "imageOutputFormat": "webp",
    "imageOutputQuality": 80,
    "img2imgPromptStrength": 0.8,
    "additionalLoraStrength": 1,
    "diffusionGuidanceScale": 3,
    "enableSpeedOptimization": false
}

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, the action ID and input payload are structured according to the specifications. The endpoint URL and request structure are illustrative and should be adjusted to fit the actual API details.

Conclusion

The gastonmiguelartillo/labelspngss2 Cognitive Action for generating images with inpainting and LoRA adjustments presents an exciting opportunity for developers to enhance their applications with advanced image generation capabilities. By leveraging these pre-built actions, you can quickly create stunning visuals tailored to specific requirements. Explore the potential of these actions in your projects and unlock new creative possibilities!