Create Stunning AI-Enhanced Images with Mason Zoom

Mason Zoom offers a powerful suite of Cognitive Actions designed to elevate your image generation capabilities. With the ability to generate AI-enhanced images using advanced techniques like img2img and inpainting, developers can easily create unique visuals tailored to their needs. This service simplifies the image creation process, allowing for customizations such as prompt inputs, dimensions, and refinement methods, making it an invaluable tool for artists, designers, and content creators alike.
Imagine crafting bespoke images for marketing campaigns, social media posts, or artistic endeavors in mere moments. The flexibility to manipulate existing images or generate entirely new ones opens up a world of possibilities. Whether you need to enhance a product photo, create compelling graphics for a presentation, or develop unique artwork, Mason Zoom is the ideal solution.
Prerequisites
To get started with Mason Zoom, you'll need a Cognitive Actions API key and a basic understanding of making API calls.
Generate AI-Enhanced Images
This action allows you to create stunning images by leveraging AI techniques. The process can either enhance an existing image or fill in areas based on a mask, providing you with a high degree of control over the final output.
Purpose
The Generate AI-Enhanced Images action solves the problem of creating high-quality visuals quickly and efficiently. By allowing for detailed customization, it empowers developers to produce images that meet specific requirements and standards.
Input Requirements
The action requires a structured input that includes:
- Image: URI of the base image for enhancement or modification.
- Mask: URI for inpainting, indicating areas to modify or keep unchanged.
- Prompt: Descriptive text to guide the image generation.
- Width & Height: Dimensions for the output image.
- Refine Mode: Style of refinement applied to the image.
- Guidance Scale: Strength of the prompt's influence on the image.
- Number of Outputs: How many images to generate.
For example, an input might look like this:
{
"width": 1024,
"height": 1024,
"prompt": "TOK, wearing a birthday hat and holding a bunny",
"refine": "no_refiner",
"guidanceScale": 10,
"numberOfOutputs": 1
}
Expected Output
The action returns a URI pointing to the generated image. For instance:
[
"https://assets.cognitiveactions.com/invocations/81cd2b33-382f-4605-91b0-af0ac388deec/e21c557c-50e2-4c70-aa4d-f6c69c13499a.png"
]
Use Cases for this Action
- Marketing Materials: Quickly generate eye-catching images for ads or social media.
- Creative Projects: Create unique artwork or illustrations based on specific prompts.
- Prototyping: Enhance product images for mockups and presentations.
- Personalized Content: Tailor images to fit specific themes or events, such as birthdays or holidays.
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 = "93a1f303-fe4e-4a87-a6af-d26de3cc118b" # Action ID for: Generate AI-Enhanced Images
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"width": 1024,
"height": 1024,
"prompt": "TOK, wearing a birthday hat and holding a bunny",
"refine": "no_refiner",
"loraScale": 0.6,
"scheduler": "K_EULER",
"guidanceScale": 10,
"applyWatermark": true,
"negativePrompt": "hair",
"promptStrength": 0.75,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8,
"numberOfInferenceSteps": 200
}
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
Mason Zoom's image generation capabilities provide developers with a robust tool for creating high-quality visuals tailored to their needs. The flexibility in input options allows for a wide range of applications, from marketing to creative projects. By integrating Mason Zoom into your workflow, you can streamline the image creation process and enhance your projects with stunning AI-generated visuals. Start exploring the possibilities today!