Generate Stunning Images with the thijssdaniels/eichholtz-bjorn-sofa Cognitive Actions

In the world of digital content creation, high-quality images can significantly enhance user engagement and experience. The thijssdaniels/eichholtz-bjorn-sofa API offers a powerful Cognitive Action to generate enhanced images with customizable parameters. This action is designed to help developers create visually appealing images tailored to their specific needs, making it easier than ever to integrate stunning visuals into applications.
Prerequisites
To get started with the Cognitive Actions for the thijssdaniels/eichholtz-bjorn-sofa, you'll need an API key for authentication. This key should be included in the request headers when calling the API. The basic structure for authentication involves passing the API key as a Bearer token, which ensures secure access to the Cognitive Actions service.
Cognitive Actions Overview
Generate Enhanced Images
Purpose:
The "Generate Enhanced Images" action allows developers to create high-quality images based on customizable parameters, including prompts, dimensions, and refinement settings. It also supports advanced features like watermarking and safety checks.
Category:
Image Generation
Input
The input for this action requires a JSON object with the following fields:
- mask (optional): URI for the input mask for inpainting.
- seed (optional): Integer value for random seed.
- image (optional): URI for the input image.
- width (default: 1024): Width of the output image in pixels.
- height (default: 1024): Height of the output image in pixels.
- prompt (default: "An astronaut riding a rainbow unicorn"): Text prompt guiding the image generation.
- refineStyle (default: "no_refiner"): Defines the refinement strategy.
- guidanceScale (default: 7.5): Intensity of classifier-free guidance.
- applyWatermark (default: true): Embed a watermark in the generated image.
- promptStrength (default: 0.8): Influence of the prompt in image-to-image modes.
- numberOfOutputs (default: 1): Number of images to generate (between 1 and 4).
- schedulingMethod (default: "K_EULER"): Algorithm for scheduling steps.
- highNoiseFraction (default: 0.8): Proportion of noise for refinement.
- loraAdditiveScale (default: 0.6): Scale for LoRA augmentation.
- negativeInputPrompt (default: ""): Undesired aspects for the generation.
- numberOfInferenceSteps (default: 50): Steps taken during denoising.
- disableSafetyVerification (default: false): Turns off safety checks.
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "A white boucle sofa in a living room with a chandelier",
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"applyWatermark": true,
"promptStrength": 0.8,
"numberOfOutputs": 4,
"schedulingMethod": "K_EULER",
"highNoiseFraction": 0.8,
"loraAdditiveScale": 0.6,
"negativeInputPrompt": "",
"numberOfInferenceSteps": 50
}
Output
The output is an array of image URLs that were generated based on the input parameters. For example, the response may look like this:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/1d8cd6d0-4196-440e-b2f7-6eccac1adf74/39c5334f-c9a5-4a69-8e33-9e9b7278d13f.png",
"https://assets.cognitiveactions.com/invocations/1d8cd6d0-4196-440e-b2f7-6eccac1adf74/54eed29f-9c92-4ba7-97eb-3de7dfaffac2.png",
"https://assets.cognitiveactions.com/invocations/1d8cd6d0-4196-440e-b2f7-6eccac1adf74/10501703-f4e4-4a71-8ddc-2f768da14e14.png",
"https://assets.cognitiveactions.com/invocations/1d8cd6d0-4196-440e-b2f7-6eccac1adf74/47f3664b-e260-42d6-afa4-0e4d36def8b1.png"
]
Conceptual Usage Example (Python):
Here’s how you can call the "Generate Enhanced Images" action using a hypothetical Cognitive Actions execution 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 = "50e133df-1925-49ca-96ac-efadd3ba2644" # Action ID for Generate Enhanced Images
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "A white boucle sofa in a living room with a chandelier",
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"applyWatermark": True,
"promptStrength": 0.8,
"numberOfOutputs": 4,
"schedulingMethod": "K_EULER",
"highNoiseFraction": 0.8,
"loraAdditiveScale": 0.6,
"negativeInputPrompt": "",
"numberOfInferenceSteps": 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 Python code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the "Generate Enhanced Images" action, and the payload is structured according to the action's input requirements.
Conclusion
The thijssdaniels/eichholtz-bjorn-sofa Cognitive Actions provide a powerful way to generate high-quality images customized to your specifications. By leveraging the flexibility of these actions, developers can create visually striking content that enhances user experiences in their applications. Experiment with different parameters to explore the vast possibilities of image generation in your projects!