Generate Stunning Images with the Big Medium Images Cognitive Actions

In today's digital landscape, harnessing the power of image generation is essential for creating engaging content, whether for marketing, art, or social media. The Big Medium Images Cognitive Actions provide developers with a powerful toolset to create customized images using the Big Medium style. With various options for inpainting, img2img transformation, and refinement techniques, you can generate high-quality images tailored to your specific needs.
Prerequisites
Before you start using the Big Medium Images Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform. This key will grant you access to the image generation capabilities.
- Basic knowledge of JSON and familiarity with making HTTP requests in your preferred programming language.
For authentication, you'll typically need to include your API key in the request headers when making API calls.
Cognitive Actions Overview
Generate Big Medium Style Images
The Generate Big Medium Style Images action allows you to create customized images with a variety of settings. You can perform inpainting, transform images, and apply various refinement techniques based on your requirements.
Input
The action accepts a JSON payload structured according to the following schema:
{
"mask": "string (optional)",
"seed": "integer (optional)",
"image": "string (optional)",
"width": 1024,
"height": 1024,
"prompt": "string",
"loraScale": 0.6,
"numOutputs": 1,
"loraWeights": "string (optional)",
"refineSteps": "integer (optional)",
"refineStyle": "string",
"scheduleType": "string",
"guidanceScale": 7.5,
"highNoiseFrac": 0.8,
"applyWatermark": true,
"negativePrompt": "string (optional)",
"promptStrength": 0.8,
"numInferenceSteps": 50,
"disableSafetyChecker": false
}
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "Black Pictograph of a robot in the style of TOK. White background. Block color, Low detail",
"loraScale": 0.8,
"numOutputs": 2,
"refineSteps": 50,
"refineStyle": "expert_ensemble_refiner",
"scheduleType": "K_EULER",
"guidanceScale": 7.5,
"highNoiseFrac": 0.8,
"applyWatermark": true,
"negativePrompt": "Color, complex, gradient background, high detail, multiple robots, negative space",
"promptStrength": 0.8,
"numInferenceSteps": 100
}
Output
Upon successful execution, the action returns an array of URLs pointing to the generated images. Here’s what you can expect as output:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/613486cb-cfb3-4c19-af4c-87f0b040ba98/aac59640-6612-4b3c-b6f8-10c7df44552e.png",
"https://assets.cognitiveactions.com/invocations/613486cb-cfb3-4c19-af4c-87f0b040ba98/f58b60a2-9d6d-4e70-81ba-2b10308980c1.png"
]
Conceptual Usage Example (Python)
Here’s how you can call the Generate Big Medium Style Images 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 = "ad4875db-b7f6-4647-99ef-095334c1dd65" # Action ID for Generate Big Medium Style Images
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "Black Pictograph of a robot in the style of TOK. White background. Block color, Low detail",
"loraScale": 0.8,
"numOutputs": 2,
"refineSteps": 50,
"refineStyle": "expert_ensemble_refiner",
"scheduleType": "K_EULER",
"guidanceScale": 7.5,
"highNoiseFrac": 0.8,
"applyWatermark": True,
"negativePrompt": "Color, complex, gradient background, high detail, multiple robots, negative space",
"promptStrength": 0.8,
"numInferenceSteps": 100
}
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 action ID is set to match the Generate Big Medium Style Images action. The payload is constructed to meet the action's requirements, and the API call is made to the specified endpoint.
Conclusion
The Big Medium Images Cognitive Actions provide a robust solution for generating customized images tailored to your needs. By leveraging the various parameters available, you can create unique images that stand out. Consider using these actions for marketing materials, creative projects, or even social media content to enhance your visual storytelling. Happy coding!