Create Stunning Images from Text Prompts with Mylora

26 Apr 2025
Create Stunning Images from Text Prompts with Mylora

Mylora is an innovative service designed to empower developers with advanced image generation capabilities. By leveraging Cognitive Actions, Mylora allows users to transform detailed text prompts into high-quality images, with customizable attributes such as aspect ratio, resolution, and advanced model options. This not only streamlines the creative process but also enhances productivity, enabling developers to focus on their core tasks while generating visually appealing content.

Imagine a scenario where you need to create unique images for a marketing campaign, an art project, or even a game development initiative. With Mylora, you can easily generate images that align perfectly with your vision, whether you require realistic representations or artistic interpretations. The service supports various use cases, including image-to-image transformations and inpainting, allowing for remarkable flexibility and creativity in your projects.

Prerequisites

Before diving into the capabilities of Mylora, ensure you have a valid Cognitive Actions API key and a basic understanding of how to make API calls.

Generate Enhanced Image

The Generate Enhanced Image action is at the heart of Mylora's image generation capabilities. This operation creates high-quality images based on text prompts and offers a range of customizable parameters to suit your specific needs. Whether you are looking for speed with the 'schnell' model or optimal quality with the 'dev' model, this action provides the tools to achieve your desired results.

Purpose

This action addresses the challenge of creating unique and high-quality images from textual descriptions, making it particularly valuable for developers looking to automate content creation or enhance visual storytelling.

Input Requirements

To use this action, you need to provide a structured input that includes a prompt, which is essential for generating the image. Additional optional parameters allow for fine-tuning, such as mask for inpainting, width and height for custom dimensions, and model to select the appropriate inference model.

Expected Output

The output will be a generated image in your specified format (e.g., webp, jpg, png), with a link to the image provided in the response.

Use Cases for this specific action

  • Marketing and Advertising: Quickly generate unique visuals tailored to specific campaigns.
  • Game Development: Create concept art or assets based on narrative descriptions.
  • Content Creation: Enhance blog posts or articles with custom images that reflect the written content.
  • Artistic Projects: Enable artists to visualize their ideas through detailed prompts, fostering creativity.

```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 = "e08c4a93-08a0-46d9-a70f-45e5dd2d3f1a" # Action ID for: Generate Enhanced Image

# 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 clear and sharp photo of Yonatan working on a computer, sitting at a desk in a modern office setting. The background is unblurred, showing an organized workspace with shelves, books, and a coffee mug on the table. The lighting is natural, with soft shadows. The photo is taken from an Android phone perspective, capturing a realistic and detailed composition, with Yonatan focused on his work.",
  "loraScale": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "outputQuality": 80,
  "enableFastMode": false,
  "megapixelCount": "1",
  "numberOfOutputs": 1,
  "guidanceStrength": 3,
  "additionalLoraScale": 1,
  "inputPromptStrength": 0.8,
  "numberOfInferenceSteps": 28
}

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
Mylora's image generation capabilities provide developers with a powerful tool for creating stunning visuals from text prompts. By simplifying the image creation process and allowing for extensive customization, Mylora enhances productivity and creativity across various applications. To get started, explore the options available within the Generate Enhanced Image action and see how you can incorporate this innovative technology into your projects.