A DALL·E 2 image generation downloader. Permits easy upload to cloud services like Google Drive.
Status: an afternoon project. Don't expect robust capabilities!
- Usage Requirements
(e) You may not use web scraping, web harvesting, or web data extraction methods to extract data from the Services, the Content, or OpenAI’s or its affiliates’ software, models or systems.
https://openai.com/api/policies/terms/
$ albaretto <openai-bearer-token> google-drive <credentials.json>
# perform OAuth 2.0 authentication with a web browser
[albaretto] [google-drive] > fetch <task-id>
✓ Fetched <image-generation-id-1> (356.89 KiB)
✓ Fetched <image-generation-id-2> (340.39 KiB)
✓ Fetched <image-generation-id-3> (279.75 KiB)
✓ Fetched <image-generation-id-4> (401.94 KiB)
[albaretto] [google-drive] > save <folder-id>
✓ Saved <image-generation-id-1>.webp to <folder-id>
✓ Saved <image-generation-id-2>.webp to <folder-id>
✓ Saved <image-generation-id-3>.webp to <folder-id>
✓ Saved <image-generation-id-4>.webp to <folder-id>
# only fetch generated images 2 and 3 (one-indexed from left to right as displayed in the UI)
[albaretto] [google-drive] > fetch <task-id> -g 2 -g 3
✓ Fetched <image-generation-id-2> (340.39 KiB)
✓ Fetched <image-generation-id-3> (279.75 KiB)
The above workflow is the same for saving to the local filesystem, i.e.
$ albaretto <openai-bearer-token> local-filesystem
[albaretto] [local-filesystem] > fetch <task-id>
...
[albaretto] [local-filesystem] > save /path/to/output/directory
...
$ git clone https://github.com/afparsons/albaretto.git
$ cd albaretto
$ python -m pip install .
Prerequisite: must have access to OpenAI's DALL·E 2
- Navigate to (and possibly log into) https://labs.openai.com/.
- Open Developer Tools in your web browser and navigate to the Network tab.
- On https://labs.openai.com/, type a prompt and click "Generate".
- Look for request to https://labs.openai.com/api/labs/tasks.
- Look for authorization in the request header. The bearer token will begin with
sess-
. - Copy the bearer token.
- https://developers.google.com/drive/api/guides/about-auth
- https://developers.google.com/workspace/guides/create-project
- https://developers.google.com/workspace/guides/create-credentials
Required scopes (documentation):
Unaffiliated informational resources:
As far as I know, there is no way to pipe |
or push >
data through Typer or Click commands.
Ideally, the command line interface would work like this:
$ albaretto <openai-bearer-token> google-drive <credentials.json>
# where `save` takes arguments folder-id and a list of files
[albaretto] [google-drive] > fetch <task-id> | save <folder-id>
But I don't know of a way to achieve the above. Instead, the fetch
command saves output into the typer.Context
, whence the data is retreived by save
.
This program does not provide full nor robust UNIX-like utilities for interacting with OpenAI's DALL·E 2 or Google Drive.
Why does this program exist? I found it tedious to save and then re-upload the images generated by OpenAI's DALL·E 2 using the user interface.
Why is it named albaretto
? Doctors Giuseppe and Mara Albaretto were patrons and collectors of Salvador Dalí's work.