Create Stunning Jellycat Style Images with Cognitive Actions

In this article, we will explore the capabilities of the cleexiang/jellycat API and its powerful Cognitive Action: Generate Jellycat Style Images. This action allows developers to generate images that reflect the whimsical and charming style of Jellycat toys, utilizing specific prompts and image processing parameters. By the end of this guide, you'll understand how to integrate this action into your applications, opening up new creative possibilities.
Prerequisites
Before getting started, make sure you have the following:
- An API key for the Cognitive Actions platform. This key will be used for authentication when making requests to the API.
- Basic knowledge of JSON and Python programming.
To authenticate your API calls, you will typically pass your API key in the request headers. This ensures that your requests are recognized and processed by the Cognitive Actions service.
Cognitive Actions Overview
Generate Jellycat Style Images
Description: This action generates images in the style of a Jellycat toy using the Flux Lora model. By providing specific prompts like "jellycat toy," you can trigger the desired style and incorporate various image processing parameters.
Category: Image Generation
Input
The input schema consists of several fields, both required and optional, as outlined below:
- prompt (required): A text prompt for image generation. Including the training phase 'trigger_word' may enhance activation of specific objects, styles, or concepts.
Example:"jellycat toy, a monkey ride bicycle in park" - mask: URI for the image mask used in inpainting mode.
- seed: Random seed for generating reproducible outputs.
- image: URI for the input image used in image-to-image or inpainting mode.
- width: Width of the generated image (valid when 'aspect_ratio' is 'custom').
- height: Height of the generated image (valid when 'aspect_ratio' is 'custom').
- goFast: Enable speed-optimized model (boolean).
- numOutputs: Sets the number of generated output images.
- guidanceScale: Adjusts the guidance scale during the diffusion process.
- outputQuality: Sets the image saving quality between 0 and 100.
- inferenceModel: Specifies the inference model to utilize (options: "dev" or "schnell").
- Additional parameters like
extraLora,loraScale,promptStrength, etc., control various aspects of image generation.
Example Input:
{
"prompt": "jellycat toy, a monkey ride bicycle in park",
"loraScale": 1,
"numOutputs": 1,
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"numInferenceSteps": 28
}
Output
The action typically returns a URL pointing to the generated image. Here’s what a sample output could look like:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/ab1473f6-528a-41b1-958c-252aaf9dcac6/6b2b0a16-a886-4b83-a6ef-5c93f688b03f.webp"
]
Conceptual Usage Example (Python)
Here’s a conceptual Python code snippet to help you call the Cognitive Actions execution endpoint for the Generate Jellycat Style Images action:
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 = "2ea617b7-8937-405b-8604-2680c160dfe3" # Action ID for Generate Jellycat Style Images
# Construct the input payload based on the action's requirements
payload = {
"prompt": "jellycat toy, a monkey ride bicycle in park",
"loraScale": 1,
"numOutputs": 1,
"guidanceScale": 3.5,
"outputQuality": 90,
"extraLoraScale": 1,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"numInferenceSteps": 28
}
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 "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The action ID is specified, and the input payload is structured according to the action's requirements.
Conclusion
The Generate Jellycat Style Images Cognitive Action provides an exciting way for developers to create whimsical images inspired by Jellycat toys. By using the specified parameters effectively, you can refine the output to suit your creative needs.
Consider integrating this action into your applications for unique image generation capabilities, and explore the various parameters to unlock new artistic possibilities!