Create Stunning Images with Vladik's Image Generation Actions

26 Apr 2025
Create Stunning Images with Vladik's Image Generation Actions

Vladik offers powerful Cognitive Actions for image generation, streamlining the process of creating high-quality, realistic images tailored to your specific needs. With features like inpainting and customizable settings, developers can easily enhance their applications with visually appealing content. Whether you are developing a marketing platform, a game, or an artistic project, Vladik simplifies image creation, saving valuable time and effort while delivering impressive results.

Imagine being able to generate unique images based on detailed prompts or modify existing images with precision. This capability can transform user experiences across various industries, from e-commerce to entertainment. By leveraging Vladik's image generation actions, developers can provide their users with personalized and engaging visuals that stand out.

Prerequisites

To get started with Vladik's Cognitive Actions, you'll need a valid API key and a basic understanding of making API calls.

Generate Enhanced Image Predictions

The "Generate Enhanced Image Predictions" action is designed to create stunning, high-quality images using advanced techniques such as inpainting and image-to-image transformations. This action allows you to customize various parameters, including aspect ratio, width, height, and image quality, ensuring that the final output meets your specific requirements. You can choose between two models: 'dev' for optimal results or 'schnell' for faster generation, making it versatile for different use cases.

Input Requirements

To use this action, you need to provide a structured input object that includes the following properties:

  • Prompt (required): A detailed description of the image you want to generate.
  • Model: Select between 'dev' or 'schnell' for the generation model.
  • Image: An optional input image for image-to-image or inpainting modes.
  • Mask: An optional mask for inpainting mode.
  • Additional parameters such as width, height, aspect ratio, output format, quality, and others can also be specified to further refine the output.

Expected Output

The action returns a URL link to the generated image, which will be a high-quality representation based on the provided prompt and parameters.

Use Cases for this Specific Action

  • Marketing and Advertising: Create promotional images tailored to specific campaigns or products, enhancing visual storytelling.
  • Content Creation: Generate unique visuals for blogs, articles, or social media posts that capture audience attention.
  • Game Development: Design characters, environments, or assets dynamically based on creative prompts, speeding up the asset creation process.
  • Art and Design: Assist artists in visualizing concepts or creating variations of their work, expanding their creative possibilities.

```python
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 = "1b9bebec-fe0e-4f04-8f72-7bba7f950d62" # Action ID for: Generate Enhanced Image Predictions

# 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": "tok  A professional and dynamic scene of a digital marketing expert giving a conference on a large stage in front of 500 attentive audience members. The expert, a confident and well-dressed individual, is speaking passionately into a microphone, exuding expertise and authority. The scene is captured from a front-facing perspective, showcasing the expert standing center stage with a clear view of their entire figure and the LED screen behind them. The shot focuses on a closeup of the expert's face, ensuring it is identical to the reference image, with clear and highly detailed features, a focused and determined expression, and perfect symmetry. Behind the expert, a massive LED screen displays a detailed and visually appealing sales funnel graphic, showcasing stages like Awareness, Interest, Decision, and Action. The stage is well-lit with modern lighting, and the audience is seated in a large auditorium, fully engaged and listening intently. The atmosphere is professional, inspiring, and futuristic, with a focus on the expert as the central figure. High-quality, realistic, and detailed rendering, emphasizing the expert's confidence, the clarity and consistency of their facial features, and the modern, high-tech environment. The face must always remain in closeup, ensuring it is the focal point of the image",
  "mainLoraScale": 1,
  "enableFastMode": false,
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "totalMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "imageOutputQuality": 80,
  "secondaryLoraScale": 1,
  "inferenceStepsCount": 28,
  "diffusionGuidanceScale": 3
}

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
Vladik's image generation actions empower developers to create stunning visuals effortlessly. With customizable options and advanced models, you can cater to a wide range of applications—whether it's for marketing, content creation, or game design. Start integrating Vladik into your projects today and unlock the potential of high-quality image generation to enhance user engagement and experience.