Create Stunning Custom Images with Dreamin Character Actions

The "Dreamin Character" service offers developers a powerful suite of Cognitive Actions designed for image generation. One of the standout features is the ability to generate custom images using inpainting techniques, allowing for intricate modifications and creative expression. This capability can significantly speed up the image creation process and simplify workflows by enabling developers to produce high-quality visuals tailored to their specific needs.
Common use cases for this service include creating unique character designs for games, generating illustrations for storytelling, or even producing marketing materials with custom graphics. Whether you're a game developer seeking to bring your characters to life or a digital artist looking to explore new creative avenues, Dreamin Character's image generation capabilities can help you achieve your artistic vision effortlessly.
To get started, you'll need a Cognitive Actions API key and a basic understanding of making API calls.
Generate Custom Image with Inpainting
The "Generate Custom Image with Inpainting" action is designed to create tailored images by leveraging advanced inpainting techniques. This action allows you to specify various input parameters, such as masks, seeds, and image dimensions, enabling you to generate unique visuals that meet your project's requirements.
Purpose
This action solves the challenge of creating custom images by allowing developers to manipulate existing images or generate new ones based on textual prompts. With options for different models, this action can cater to various needs, whether you require speed or detailed output.
Input Requirements
To use this action, you must provide a prompt that describes the image you want to create. Additionally, you can include:
- An image or mask URI for inpainting.
- Parameters like seed for reproducibility, width and height for custom dimensions, and aspect ratio.
- Options for image format, output count, quality, and various intensities for guidance and LoRA weights.
Expected Output
The output will be a custom image generated based on your specifications, available in formats such as webp, jpg, or png. The action can return multiple images based on the output count specified.
Use Cases for this specific action
- Game Development: Create unique character designs or environments by inpainting on existing images.
- Illustration: Generate specific scenes or concepts for books and other media by providing descriptive prompts.
- Marketing: Produce tailored graphics for campaigns, allowing for quick iteration and adjustments based on feedback.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "f490bfb0-3cbe-441c-a5b7-59ff09bc3295" # Action ID for: Generate Custom Image with Inpainting
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"model": "dev",
"prompt": "a TOK chibi character, Iron Man, empty background",
"fastMode": false,
"aspectRatio": "1:1",
"imageFormat": "webp",
"outputCount": 1,
"imageQuality": 80,
"guidanceScale": 3,
"loraIntensity": 1,
"imageMegapixels": "1",
"promptIntensity": 0.8,
"inferenceStepCount": 28,
"additionalLoraIntensity": 1
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
The Dreamin Character service provides developers with a robust solution for generating custom images quickly and efficiently. By leveraging the inpainting capabilities, you can create unique visuals tailored to your project needs, whether for games, illustrations, or marketing materials. With easy integration and versatile options, the next step is to explore how you can implement these Cognitive Actions into your workflows to enhance your creative projects.