Create Stunning Images with the nasserfq/andalusian-style Cognitive Action

25 Apr 2025
Create Stunning Images with the nasserfq/andalusian-style Cognitive Action

The nasserfq/andalusian-style API offers developers an exciting way to generate images inspired by traditional Andalusian artistic patterns. Utilizing a custom-tuned SDXL model, this API excels in producing visuals that reflect the rich aesthetics of Andalusian culture. By leveraging pre-built Cognitive Actions, developers can enhance their applications with sophisticated image generation capabilities without the need for extensive machine learning expertise.

Prerequisites

To get started with the nasserfq/andalusian-style Cognitive Actions, you will need to have an API key for accessing the service. Ensure that your environment is set up to make HTTP requests, and you understand how to pass the API key in the headers of your requests. This typically involves adding an Authorization header with your API key.

Cognitive Actions Overview

Generate Andalusian Style Images

The Generate Andalusian Style Images action allows you to create images that encapsulate the artistic essence of Andalusia. Users can input prompts that begin with "In the style of Andalusia" to achieve optimal results. This action falls under the category of image-generation.

Input

The input for this action requires a JSON object that can include the following fields:

  • mask (optional): URI of the input mask for inpaint mode.
  • seed (optional): An integer to specify a random seed for image generation.
  • image (optional): URI of the input image for img2img or inpaint mode.
  • width (optional, default: 1024): Width of the output image in pixels.
  • height (optional, default: 1024): Height of the output image in pixels.
  • prompt (required): Textual input to guide image generation (e.g., "In the style of Andalusia, Alhambra palace in granada.").
  • loraScale (optional, default: 0.6): LoRA additive scale for model customization.
  • numOutputs (optional, default: 1): Number of images to generate (1 to 4).
  • guidanceScale (optional, default: 7.5): Scale for classifier-free guidance.
  • numInferenceSteps (optional, default: 50): Number of denoising steps during image generation.
  • schedulingAlgorithm (optional, default: "K_EULER"): Algorithm used for scheduling the generation process.

Here’s an example of the input JSON payload:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of Andalusia, Alhambra palace in granada.",
  "loraScale": 0.6,
  "numOutputs": 1,
  "guidanceScale": 7.5,
  "highNoiseFrac": 0.8,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "refinementStyle": "no_refiner",
  "numInferenceSteps": 50,
  "schedulingAlgorithm": "K_EULER"
}

Output

Upon successful execution, the action typically returns a URL to the generated image. Here’s an example of the expected output:

[
  "https://assets.cognitiveactions.com/invocations/999b2914-96d3-41b0-83bb-6ccde1621f20/a67ff863-d7bd-4cd1-a956-1d274afe01b0.png"
]

Conceptual Usage Example (Python)

Below is a conceptual example of how to call the Generate Andalusian Style Images action using Python. This snippet assumes you have set your API key and endpoint correctly.

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 = "4b08e63c-d576-4815-ac9f-93d06205ebd8"  # Action ID for Generate Andalusian Style Images

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of Andalusia, Alhambra palace in granada.",
    "loraScale": 0.6,
    "numOutputs": 1,
    "guidanceScale": 7.5,
    "highNoiseFrac": 0.8,
    "applyWatermark": true,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "refinementStyle": "no_refiner",
    "numInferenceSteps": 50,
    "schedulingAlgorithm": "K_EULER"
}

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 is specified, and the input payload is structured according to the requirements of the Generate Andalusian Style Images action. The response from the API will be printed in a formatted manner.

Conclusion

The nasserfq/andalusian-style Cognitive Action opens up new avenues for developers looking to incorporate rich, culturally inspired visuals into their applications. By using the Generate Andalusian Style Images action, you can seamlessly create stunning images reflective of Andalusian aesthetics. Explore the possibilities and consider how you might utilize these capabilities in your next project!