Create Stunning Images in the Style of Obra Dinn with Cognitive Actions

The doriandarko/sdxl-obradinn API offers developers a powerful tool for generating images inspired by the unique artistic style of the game "The Return of The Obra Dinn". By utilizing the Cognitive Actions available in this API, you can seamlessly create captivating images that are monochromatic, grainy, and rich in contrast, all while customizing various parameters to fit your needs. This article will guide you through the capabilities of the "Generate Image In Style of Obra Dinn" action, detailing how to integrate it into your applications effectively.
Prerequisites
Before you start using the Cognitive Actions, ensure you have:
- An API key for the Cognitive Actions platform.
- Basic knowledge of handling API requests in your application.
- Familiarity with JSON structure for input and output.
To authenticate your requests, you will typically include your API key in the headers of your request like so:
Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY
Cognitive Actions Overview
Generate Image In Style of Obra Dinn
This action generates images in a unique style inspired by the game "The Return of The Obra Dinn". You can customize the output using various parameters such as image dimensions, mask application, guidance scaling, and refinement methods.
- Category: image-generation
Input
The input for this action is structured as follows:
{
"mask": "string (uri, optional)",
"seed": "integer (optional)",
"image": "string (uri, optional)",
"width": "integer (default: 1024)",
"height": "integer (default: 1024)",
"prompt": "string (default: 'An astronaut riding a rainbow unicorn')",
"loraScale": "number (default: 0.6)",
"numOutputs": "integer (default: 1, range: 1-4)",
"loraWeights": "string (optional)",
"refineSteps": "integer (optional)",
"refineStyle": "string (default: 'no_refiner')",
"guidanceScale": "number (default: 7.5)",
"highNoiseFrac": "number (default: 0.8)",
"applyWatermark": "boolean (default: true)",
"negativePrompt": "string (default: '')",
"promptStrength": "number (default: 0.8)",
"schedulerMethod": "string (default: 'K_EULER')",
"numInferenceSteps": "integer (default: 50)",
"disableSafetyChecker": "boolean (default: false)"
}
Example Input:
Here's an example of a JSON payload you might use to generate an image:
{
"width": 1024,
"height": 1024,
"prompt": "in the style of obradnn, a ship sailing in the ocean, moon in the sky.",
"loraScale": 0.6,
"numOutputs": 1,
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"highNoiseFrac": 0.95,
"applyWatermark": true,
"negativePrompt": "Colorful, Cartoonish, Multicolored",
"promptStrength": 0.8,
"schedulerMethod": "K_EULER",
"numInferenceSteps": 50
}
Output
The action typically returns a URL to the generated image. Here’s an example of the output you might receive:
[
"https://assets.cognitiveactions.com/invocations/44305baf-98d4-4b1b-b1cf-2833981e3d41/c969feaf-660b-4d38-bd08-8291e36b4ffa.png"
]
Conceptual Usage Example (Python)
Here’s a conceptual Python code snippet demonstrating how you might call the Cognitive Actions execution endpoint to generate an image:
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 = "1e74cae3-c72e-4df5-ba40-9b3fd70a7006" # Action ID for Generate Image In Style of Obra Dinn
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "in the style of obradnn, a ship sailing in the ocean, moon in the sky.",
"loraScale": 0.6,
"numOutputs": 1,
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"highNoiseFrac": 0.95,
"applyWatermark": true,
"negativePrompt": "Colorful, Cartoonish, Multicolored",
"promptStrength": 0.8,
"schedulerMethod": "K_EULER",
"numInferenceSteps": 50
}
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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable contains the input JSON structured according to the action's requirements. The response will include the URL of the generated image.
Conclusion
The "Generate Image In Style of Obra Dinn" Cognitive Action empowers developers to create distinctive images that capture the essence of the game's artistic style. By customizing parameters such as prompts, dimensions, and refinement methods, you can tailor the output to meet your specific needs. Consider exploring additional features and use cases to fully leverage this powerful tool in your applications. Happy coding!