Skip to main content

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

Project description

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

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

Todo

  • Build an async wrapper which is non-blocking and can be used with async code (e.g. aiohttp, discord.py)

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

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

craiyon.py-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file craiyon.py-0.1.0.tar.gz.

File metadata

  • Download URL: craiyon.py-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6

File hashes

Hashes for craiyon.py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aebafebf98e757b526e3e18c2ac666cdd122b67ca54aadd7d14e83145febe5d5
MD5 01648063bd637dd9f888d68ace9e74ad
BLAKE2b-256 41211e897e1dc486a3f00dc693a69769b3e33c11c485bc9e54dac6a0c637631e

See more details on using hashes here.

Supported by

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