Create Stunning Custom Images with Youri's Image Generation Action

In the digital age, the ability to generate custom images quickly and efficiently can significantly enhance the creative process for developers and designers alike. Youri offers a powerful Cognitive Action that enables developers to create unique images through advanced image-to-image transformation and inpainting modes. With features like adjustable prompt intensity, various aspect ratios, and model weight options, this action simplifies the image generation process, making it accessible and efficient for a variety of applications.
Whether you are looking to produce artwork for a project, enhance marketing materials, or create personalized content for social media, Youri's image generation capabilities are versatile and robust. Developers can leverage this functionality to automate image creation, ensuring consistency and quality across multiple outputs.
Prerequisites
To get started with Youri's image generation action, you'll need an API key for the Cognitive Actions service and a basic understanding of making API calls.
Generate Custom Image
The Generate Custom Image action allows users to create images tailored to specific prompts, utilizing powerful image processing techniques. This action addresses the need for high-quality, customized imagery without the need for extensive graphic design skills.
Input Requirements
The input for this action is structured as a JSON object that requires at least a prompt. Other optional parameters allow for fine-tuning the output:
- prompt: A textual description guiding the image generation.
- image: A URI for the input image (for image-to-image transformations).
- mask: A URI for the image mask used in inpainting mode.
- width: Desired width of the generated image (when aspect ratio is set to 'custom').
- height: Desired height of the generated image (when aspect ratio is set to 'custom').
- aspectRatio: Defines the aspect ratio of the output image.
- outputCount: Specifies how many images to generate (up to 4).
- outputFormat: The desired file format for the output (webp, jpg, png).
- inferenceModel: Choose between 'dev' for detailed results or 'schnell' for faster outputs.
- Additional parameters such as guidanceScale, promptStrength, and imageMegapixels allow for further customization.
Expected Output
The expected output is a URI link to the generated image(s). Depending on the input parameters, multiple images can be returned, each reflecting the specified prompt and settings.
Use Cases for this specific action
- Art Creation: Artists can use this action to generate unique artwork based on their descriptions, speeding up the creative process.
- Marketing Content: Marketers can quickly create visuals that align with campaign themes, ensuring fresh content across platforms.
- Game Development: Game developers can generate character designs or environments based on specific prompts, enhancing the visual aspect of their games.
- Social Media: Content creators can produce tailored images for posts or stories, maintaining a consistent aesthetic across their profiles.
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 = "16fd384b-5d3b-4da0-8992-2f9f6d90c803" # Action ID for: Generate Custom Image
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"image": "https://replicate.delivery/pbxt/MHhi2Pc9Ve3gHXHwlvSPW2MrIOHT5lM27N81YkG5PpI6qixr/IMG_0622.webp",
"goFast": false,
"prompt": "i want you to make the same picture of TOK, with a black hat and a black tshirt holding the black paper, in the middle of a full crowded football stadium",
"loraScale": 1,
"aspectRatio": "1:1",
"outputCount": 1,
"outputFormat": "jpg",
"guidanceScale": 3,
"outputQuality": 80,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageMegapixels": "1",
"inferenceStepCount": 28,
"additionalLoraScale": 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
Youri's image generation action empowers developers and creators to produce high-quality custom images with ease. By automating the image creation process, it not only saves time but also enhances creativity, allowing for rapid iteration and experimentation. Whether for professional projects or personal use, this action offers a valuable tool for anyone looking to elevate their visual content.
As a next step, consider exploring different prompts and settings to fully harness the capabilities of Youri, and integrate this action into your projects for stunning results.