This library provides programmatic access to the DALL·E 2 API in Python

Overview

pydalle: A DALL·E 2 API Wrapper for Python

PyPI - Python Version PyPI - Wheel PyPI - License

This library provides basic programmatic access to the DALL·E 2 API.

The intent of this library is to provide researchers with a means to easily layout results from DALL·E 2 into a jupyter notebook or similar.

Installation

pip install pydalle

If you want to use sync methods, also make sure you have the requests library installed.

pip install requests

If you want to use async methods, also make sure you have the aiohttp library installed.

pip install aiohttp

Tips

  • Get access by signing up for the DALL·E 2 waitlist.

  • Ensure your usage of DALL·E 2 abides by DALL·E 2's content policy and terms of use.

  • Be mindful about how easy this library makes it for you to spend your money / DALL·E 2 credits.

Features

  • get_bearer_token / get_bearer_token_async: Get a bearer token from username and password
  • get_task / get_task_async: Get a task by ID
  • get_tasks / get_tasks_async: Get tasks created after a given timestamp
  • create_text2im_task / create_text2im_task_async: Create a task to generate an image from a text
  • create_variations_task / create_variations_task_async: Create a task to generate variations of an image
  • create_inpainting_task / create_inpainting_task_async: Create a task to generate an image from a mask and caption
  • poll_for_task_completion / poll_for_task_completion_async: Poll for a task until it is complete

Image input

All the following notes on method usage also apply to each method's corresponding async version.

  • create_variations_task and create_inpainting_task both accept a parameter called parent_id_or_image.
    • For create_variations_task, it is required.
    • For create_inpainting_task, it will default to the value of the image_mask parameter if not provided.
    • It can be a string in any of the following formats:
      • A "generation ID" (format: generation-[a-zA-Z0-9]{24}) -- can be obtained with prefix included from a task with task.generations[i].id
      • A "prompt ID" (format: prompt-[a-zA-Z0-9]{24}) -- can be obtained with prefix included from a task with task.prompt_id or task.prompt.id
      • A base64-encoded PNG image decoded as a string -- full examples in dev.ipynb and dev.py
  • create_inpainting_task also accepts the parameter image_mask
    • It must be a base64-encoded PNG image decoded as a string -- full examples in dev.ipynb and dev.py

Examples

See the following files for examples:

  • dev.ipynb - Example of using the library in a jupyter notebook
  • dev.py - Example of using the library in a python script
  • dev_async.py - Example of using the library in a python script using asyncio

Useful tools

While not dependencies of this library, the following tools are useful companions when working with images:

  • PIL: pip install Pillow
    • Displaying an image in a notebook or in a Python script
    • Adding an alpha channel to an image (for creating masks)
    • Converting an image to PNG format (for uploading to DALL·E 2)
    • Resizing, cropping, padding, and masking images (etc.)
    • Saving images to disk
  • matplotlib: pip install matplotlib
    • Arranging images in a grid for display
  • numpy: pip install numpy
    • Vectorization of image processing operations (if you find yourself doing a lot of slow loops over pixels, try putting the image in a numpy array and vectorizing the loops)
You might also like...

DNS Auto Update Dynamic IP, It is possible to check the Public IP on the router, if the ISP provides a Private IP, this program will reconnect the PPOE until the ISP provides a Public IP, then update the DNS on your provider.

DNS Auto Update Dynamic IP It is possible to check the Public IP on the router, if the ISP provides a Private IP, this program will reconnect the PPOE

Apr 9, 2022

This library provides a pure Python, asynchronous interface for the Telegram Bot API. It's compatible with Python versions 3.7+

Telegram-bot API (in Python) This library provides a pure Python, asynchronous interface for the Telegram Bot API. It's compatible with Python version

Dec 20, 2022

bevigil-cli provides a unified command line interface and python library for using BeVigil OSINT API.

bevigil-cli provides a unified command line interface and python library for using BeVigil OSINT API.

bevigil-cli bevigil-cli provides a unified command line interface and python library for using BeVigil OSINT API. Getting Started Installation The eas

Jan 4, 2023

Python package providing access to the Keycloak API forked from python-keycloak

Adamatics Keycloak adamatics-keycloak is a Python package providing access to the Keycloak API. This is a forked version of the python-keycloak librar

May 19, 2022

Flexia (Flexible Artificial Intelligence) is an open-source library that provides a high-level API for developing accurate Deep Learning models for all kinds of Deep Learning tasks such as Classification, Regression, Object Detection, Image Segmentation, etc.

Flexia (Flexible Artificial Intelligence) is an open-source library that provides a high-level API for developing accurate Deep Learning models for all kinds of Deep Learning tasks such as Classification, Regression, Object Detection, Image Segmentation, etc.

Flexia (Flexible Artificial Intelligence) is an open-source library that provides a high-level API for developing accurate Deep Learning models for all kinds of Deep Learning tasks such as Classification, Regression, Object Detection, Image Segmentation, etc.

Dec 10, 2022

FHIRPACK (FHIR Python Analysis Conversion Kit) is a general purpose library that simplifies the access, analysis and representation of FHIR and EHR data

FHIRPACK (FHIR Python Analysis Conversion Kit) is a general purpose library that simplifies the access, analysis and representation of FHIR and EHR data. FHIRPACK was designed and developed at Institute for Artificial Intelligence in Medicine (IKIM) and the Database Systems Research Group of the University of Heidelberg (HDDBS).

Dec 17, 2022

Template for fast api with uvicorn, straight access and http basic auth

FastAPI Framework with Free and Authenticated Routes Required / Recommended Virtual Environment for running directly on your machine Docker and Docker

Dec 15, 2022

Build API with ASGI in AWS Lambda with API Gateway HTTP API or REST API, or with Function URL ✨

asgi-aws Build API with ASGI in AWS Lambda with API Gateway HTTP API or REST API, or with Function URL ✨ Installation pip install asgi_aws Example Cre

Sep 23, 2022

PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library

PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library

PyAudio provides Python bindings for PortAudio v19, the cross-platform audio I/O library. With PyAudio, you can easily use Python to play and record audio on a variety of platforms, such as GNU/Linux, Microsoft Windows, and Apple macOS.

Sep 21, 2022
Comments
  • Add a unified solution to keep all library messages in one single place

    Add a unified solution to keep all library messages in one single place

    Can I collaborate adding a unified solution to keep all library messages in one single place? I mean creating a file with a class to easily handle and maintain things like:

    OPENAI_AUTH0_SCOPE = "openid profile email offline_access" File: /functional/assumptions.py

    raise FlowError("Failed to get credit summary", r) File: /functional/api/flow/labs.py

    Please let me know to start working on this. Regards.

    opened by daiangan 0
Releases(0.2.0)
Owner
Michael Phelps
Michael Phelps
ZarrDAP is a FastAPI project that provides access to Zarr and NetCDF data in remote object storage using the Open-source Project for a Network Data Access Protocol (OPeNDAP).

ZarrDAP OPeNDAP for Zarr! ZarrDAP is a FastAPI project that provides access to Zarr and NetCDF data in remote object storage using the Open-source Pro

null 33 Dec 10, 2022
The open-source data-centric IDE for NLP. Combining programmatic labeling, extensive data management and neural search capabilities.

Open-source data-centric IDE for NLP. Combining (semi-)automated labeling, extensive data management and neural search capabilities. Kern AI refinery

Kern AI 1.1k Dec 29, 2022
A programmatic attempt to find yourself on Google Maps Streetview using your Google Maps Location history.

Streetview Collision Detector A programmatic attempt to help you find yourself on Google Maps Streetview using your Google Maps Location history. What

Ryan Bateman 4 Nov 16, 2022
Use DALL·E 2 in Python

Get Access labs.openai.com/waitlist Go to https://labs.openai.com/ Open Network Tab in Developer Tools Type a promt and press "Generate" Look for fetc

fabi.s 150 Jan 7, 2023
Implementation of DALL-E 2, OpenAI's updated text-to-image synthesis neural network, in Pytorch

DALL-E 2 - Pytorch Implementation of DALL-E 2, OpenAI's updated text-to-image synthesis neural network, in Pytorch. Yannic Kilcher summary | AssemblyA

Phil Wang 8.6k Jan 1, 2023
Discord bot for DALL-E Mini.

dalle-mini-discord A simple Discord bot written in Python designed around the DALL-E Mini model. Hosted Bot If you don't feel like hosting this bot yo

Avery 2 Sep 14, 2022
This is a plugin for Krita that enables you to use DALL·E 2 from within Krita.

Krita Copilot Krita Copilot is a plugin for Krita that enables you to use DALL·E 2 from within Krita. Krita.Copilot.mp4 Tips Get access by signing up

Michael Phelps 16 Nov 14, 2022
DALL·E mini as a Discord bot? Say no more!

DALL·E Mini DALL·E mini as a discord bot. Use !help to see the commands. You can deploy the bot to heroku as a starting point. Fill out data.yaml and

Rawand Ahmed Shaswar 38 Dec 22, 2022
This contains the Flax model of min(DALL·E) and code for converting it to PyTorch

min(DALL·E) Flax This is a minimal implementation of Boris Dayma's DALL·E Mini in flax. It has been stripped to the bare essentials necessary for doin

Brett Kuprel 43 Oct 30, 2022
Inverse DALL-E for Optical Character Recognition

Inverse DALL-E for Optical Character Recognition Introduction This is a research project to apply DALLE-E for Korean optical character recognition tas

Jungwoo Park 35 Nov 21, 2022