Create Stunning Newspaper Style Illustrations with Cognitive Actions

As developers, we are always on the lookout for tools that can enhance our applications and bring creativity to life. The tudortotolici/newspaper_illustration API offers a unique capability through its Cognitive Actions, allowing you to generate striking black-and-white, cartoon-style illustrations reminiscent of classic newspaper art. These pre-built actions make it easier to add expressive visual content to your projects without needing extensive graphic design skills.
Prerequisites
Before you can start using the Cognitive Actions, you will need to ensure that you have the following:
- An API key for the Cognitive Actions platform.
- Basic familiarity with making HTTP requests, especially in JSON format.
- A development environment set up with Python to test and integrate the actions.
Authentication typically involves passing your API key in the headers of your requests, ensuring secure access to the Cognitive Actions service.
Cognitive Actions Overview
Generate Newspaper Style Illustration
The Generate Newspaper Style Illustration action is designed to create detailed black-and-white illustrations that capture everyday scenes, making it ideal for applications involving storytelling, journalism, or creative content generation.
Input
The action requires a JSON object that includes various fields. Here’s an overview of the required and optional inputs:
- Required:
prompt: A descriptive string that guides the image generation process.
- Optional:
mask: URI for an image mask used in inpainting mode.seed: Integer for reproducible generation.image: URI for an input image used in image-to-image or inpainting mode.width: Integer for the image width in pixels (when aspect ratio is custom).height: Integer for the image height in pixels (when aspect ratio is custom).goFast: Boolean to enable faster predictions.aspectRatio: String to specify the image aspect ratio.outputCount: Integer specifying the number of output images.outputFormat: String for the file format of the output images.guidanceScale: Number for the scale of guidance during the diffusion process.outputQuality: Integer for the quality level of output images.inferenceModel: String specifying the model used for inference.inferenceStepCount: Integer specifying the number of denoising steps.additionalLoraScale: Number adjusting the intensity of additional LoRA application.additionalLoraWeights: Source for additional LoRA weights.safetyCheckerDisabled: Boolean to disable the safety checker.
Here’s an example of the JSON payload you would use to invoke this action:
{
"prompt": "TOKNWSILL, Create a black-and-white cartoon-style drawing with people engaged in everyday activities, featuring familiar objects in various common settings. In a tense hospital corridor, a group of surgeons huddles in whispered conversations, casting furtive glances at a glimmering envelope being discreetly passed from one pair of hands to another, under the watchful eye of a skeptical assistant holding a clipboard.",
"loraScale": 1,
"aspectRatio": "21:9",
"outputCount": 1,
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 100,
"inferenceModel": "schnell",
"inferenceStepCount": 28,
"additionalLoraScale": 0.8
}
Output
The action will typically return a JSON array containing URLs to the generated images. Here’s an example of a successful output:
[
"https://assets.cognitiveactions.com/invocations/11ac2fa6-9ae5-46e1-a02e-27049484fdaa/2f829dc7-df09-4dae-94a7-71c79cfb26ce.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Newspaper Style Illustration 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 = "cb56a7e2-9a86-426b-b977-ed72caca5bcf" # Action ID for Generate Newspaper Style Illustration
# Construct the input payload based on the action's requirements
payload = {
"prompt": "TOKNWSILL, Create a black-and-white cartoon-style drawing with people engaged in everyday activities, featuring familiar objects in various common settings. In a tense hospital corridor, a group of surgeons huddles in whispered conversations, casting furtive glances at a glimmering envelope being discreetly passed from one pair of hands to another, under the watchful eye of a skeptical assistant holding a clipboard.",
"loraScale": 1,
"aspectRatio": "21:9",
"outputCount": 1,
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 100,
"inferenceModel": "schnell",
"inferenceStepCount": 28,
"additionalLoraScale": 0.8
}
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, replace the COGNITIVE_ACTIONS_API_KEY and the endpoint with actual values. The action ID should match the one for generating the newspaper-style illustration. The payload is structured according to the input schema required by the action.
Conclusion
The tudortotolici/newspaper_illustration Cognitive Actions provide a powerful and flexible way to integrate visually captivating illustrations into your applications. By utilizing the Generate Newspaper Style Illustration action, you can easily create unique artwork that enhances storytelling and user engagement.
Consider experimenting with the various optional parameters to tailor the illustrations further to suit your needs. Happy coding!