Skip to content

Unofficial API Wrapper for craiyon.com (DAL-E-MINI). Generate awesome images from text tokens.

License

Notifications You must be signed in to change notification settings

tako-discord/craiyon.py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

craiyon.py

API Wrapper for craiyon (formerly DAL-E-MINI) to generate awesome images from text tokens.

Badges

Provided By: shields.io

PyPI Version PyPI Downloads Apache License 2.0 Connect On Discord Code Lines Code Size Pull Requests Issues Contributors

Acknowledgements

Authors

Contributors

Installation

The easiest way to install craiyon.py is using pip

  pip install -U craiyon.py

Or just manually clone the repository and build the wheel

Usage / Examples

Generate and save the images

from craiyon import Craiyon

generator = Craiyon() # Instantiates the api wrapper
result = generator.generate("Photorealistic image of shrek eating earth")
result.save_images() # Saves the generated images to 'current working directory/generated', you can also provide a custom path

image

Use the images in your code without saving

from craiyon import Craiyon
from PIL import Image # pip install pillow
from io import BytesIO
import base64

generator = Craiyon() # Instantiates the api wrapper
result = generator.generate("Professional photo of Obama flashing a flag with his last name") # Generates 9 images by default and you cannot change that
images = result.images # A list containing image data as base64 encoded strings
for i in images:
    image = Image.open(BytesIO(base64.decodebytes(i.encode("utf-8"))))
    # Use the PIL's Image object as per your needs

image

Async Usage / Examples

Generate and save the images

from craiyon import Craiyon
import asyncio


async def main():
    generator = Craiyon() # Instantiates the api wrapper
    result = await generator.async_generate("Photorealistic image of shrek eating earth")
    await result.async_save_images() # Saves the generated images to 'current working directory/generated', you can also provide a custom path
    
asyncio.run(main())

Todo

None!

Contributing

Contributions are always welcome!

  • Fork this repository.
  • Make the changes in your forked repositry.
  • Make sure to fetch upstream before generating a PR.
  • Generate a pull request.

Please adhere to the GitHub's code of conduct for contributions and contributors.

License

Apache License 2.0

About

Unofficial API Wrapper for craiyon.com (DAL-E-MINI). Generate awesome images from text tokens.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%