Create Stunning Sketchnotes with the justmalhar/sxdl-sketchnotes Cognitive Actions

In the ever-evolving landscape of digital creativity, the justmalhar/sxdl-sketchnotes API offers developers a powerful tool for generating unique sketchnote images. By utilizing the SDXL model fine-tuned specifically for this artistic style, you can create visually appealing sketchnotes with customizable options that enhance creativity and output quality. The pre-built Cognitive Actions streamline the integration process, allowing developers to focus on innovation rather than the intricacies of image generation.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Familiarity with JSON format for structuring your input and output data.
- Basic knowledge of making HTTP requests in your preferred programming language.
For authentication, you will typically pass your API key in the request headers, ensuring secure and authorized access to the Cognitive Actions.
Cognitive Actions Overview
Generate Sketchnote Image
The Generate Sketchnote Image action allows you to produce images in a sketchnote style, enhancing your visual storytelling. This action is categorized under image generation and provides comprehensive control over the output through various parameters.
Input
The input structure for this action is defined by the following schema:
{
"mask": "string (uri)",
"seed": "integer",
"image": "string (uri)",
"width": "integer (default: 1024)",
"height": "integer (default: 1024)",
"prompt": "string (default: 'An astronaut riding a rainbow unicorn')",
"refine": "string (default: 'no_refiner')",
"scheduler": "string (default: 'K_EULER')",
"modelWeights": "string",
"guidanceScale": "number (default: 7.5)",
"inversePrompt": "string (default: '')",
"applyWatermark": "boolean (default: true)",
"inferenceSteps": "integer (default: 50)",
"numberOfOutputs": "integer (default: 1)",
"refinementSteps": "integer",
"highNoiseFraction": "number (default: 0.8)",
"inputPromptStrength": "number (default: 0.8)",
"lowRankAdaptationScale": "number (default: 0.6)",
"disableImageSafetyChecker": "boolean (default: false)"
}
Here's an example of a JSON payload that you can use to invoke this action:
{
"width": 1024,
"height": 1024,
"prompt": "a sketchnote photo of TOK explaining types of sorting algorithms",
"refine": "expert_ensemble_refiner",
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"inversePrompt": "",
"applyWatermark": false,
"inferenceSteps": 50,
"numberOfOutputs": 4,
"highNoiseFraction": 0.8,
"inputPromptStrength": 0.8,
"lowRankAdaptationScale": 0.6
}
Output
The action returns an array of URLs pointing to the generated sketchnote images. Here’s an example of the output you can expect:
[
"https://assets.cognitiveactions.com/invocations/.../image1.png",
"https://assets.cognitiveactions.com/invocations/.../image2.png",
"https://assets.cognitiveactions.com/invocations/.../image3.png",
"https://assets.cognitiveactions.com/invocations/.../image4.png"
]
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet demonstrating how to execute the Generate Sketchnote Image action using a hypothetical Cognitive Actions endpoint:
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 = "8bdd283f-7cef-42e9-a959-682498d878d6" # Action ID for Generate Sketchnote Image
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "a sketchnote photo of TOK explaining types of sorting algorithms",
"refine": "expert_ensemble_refiner",
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"inversePrompt": "",
"applyWatermark": False,
"inferenceSteps": 50,
"numberOfOutputs": 4,
"highNoiseFraction": 0.8,
"inputPromptStrength": 0.8,
"lowRankAdaptationScale": 0.6
}
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 the API key and endpoint with your specific credentials. The action ID is set for the Generate Sketchnote Image action, and the payload is structured based on the required input. The output will include URLs to the generated images, allowing for immediate use in your applications.
Conclusion
The justmalhar/sxdl-sketchnotes Cognitive Actions provide a powerful avenue for developers looking to enhance their applications with creative sketchnote images. By leveraging this action, you can effortlessly generate stunning visuals tailored to your specific needs. Next steps could include experimenting with different prompts, refining techniques, or integrating this functionality into larger projects that benefit from unique visual content. Happy coding!