Skip to main content

A wrapper for the leonardo.ai image generation

Project description

Image Generation with Leonardo Library

This document outlines the process of generating images using the Leonardo library in Python, as demonstrated in the provided code snippet.

Overview

The code snippet demonstrates how to use the Leonardo class from the leonardoWrapper module to generate an image based on a textual prompt. The example generates an image of a fantastical scene inside an ancient, otherworldly library.

Steps

  1. Initialization: The Leonardo class is initialized with the account's cookie (since a captcha was added and I don't want to reveal my turnstile solver).

    from leonardoWrapper import Leonardo
    
    leonardo = Leonardo(cookie="your_cookie")
    

    Note: Replace your_cookie with your actual cookie.

  2. Creating an Image Generation Request: An image generation request is created with specific parameters such as the prompt, number of images, model ID, model version, image dimensions, and guidance scale.

    get_generation_id = leonardo.create_generate_image(
        prompt="Create a fantastical and visually stunning scene inside an ancient, otherworldly library...",
        amount_of_images=1,
        model_id="model_id",
        sd_version="model_version", # for some models you have to provide the sd_version
        width=1024,
        height=768,
        guidance_scale=7
    )
    

    Note: Replace model_identifier and model_version with the specific model ID and version you wish to use. For a list of available models and their versions, see models.md. Please note that you can run gen_models_md.py to update the documentation with the latest model information.

  3. Waiting for Image Generation: The script waits for the image generation process to complete.

    leonardo.wait_for_image_generation(creation_id=get_generation_id)
    
  4. Retrieving the Generated Image: The generated image is retrieved, and its details are printed.

    generated_image = leonardo.get_image_generation(creation_id=get_generation_id)
    
    print(generated_image)
    print(generated_image["generated_images"][0]["url"])
    

Conclusion

This guide introduces the fundamental steps for generating images with the Leonardo library. It encompasses the initialization of the Leonardo class, formulation of an image generation request, supervision of account management throughout the generation phase, and the final retrieval of the created image.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leonardowrapper-1.1.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leonardowrapper-1.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file leonardowrapper-1.1.2.tar.gz.

File metadata

  • Download URL: leonardowrapper-1.1.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for leonardowrapper-1.1.2.tar.gz
Algorithm Hash digest
SHA256 4e0e3c1645d2aeb2bbaa37b5fe1e82e71ccb5a3e18c3aa907645112dc298f236
MD5 a50ffdde474e4707006ec77a5ef24632
BLAKE2b-256 4fd853ea4307b2e37e899e3a0c415d924412f12f320aac0f86ce00cf05c1cce5

See more details on using hashes here.

File details

Details for the file leonardowrapper-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for leonardowrapper-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d1bca2519974baa45cfe6228f26500182cd1a3f9a7dcbec4a71b8b946963bd39
MD5 7c1e850d2dc5fbb6f3411b952b2e39f7
BLAKE2b-256 c9c0b205f05bb046552ab87055abf68479ca53a08d9ea3f6146720d943634145

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page