Create Disco Diffusion artworks in one line
Project description
Create compelling Disco Diffusion artworks in one line
DiscoArt is an elegant way of creating compelling Disco Diffusion[*] artworks for generative artists, AI enthusiasts and hard-core developers. DiscoArt has a modern & professional API with a beautiful codebase, ensuring high usability and maintainability. It introduces handy features such as result recovery and persistence, gRPC/HTTP serving w/o TLS, post-analysis, easing the integration to larger cross-modal or multi-modal applications.
[*] Disco Diffusion is a Google Colab Notebook that leverages CLIP-Guided Diffusion to allow one to create compelling and beautiful images from text prompts.
👼 Available to all: fully optimized for Google Colab free tier! Perfect for those who don't own GPU by themselves.
🎨 Focus on creating not coding: one-liner create()
with a Pythonic interface, autocompletion in IDE, and of course powerful features. Fetch real-time results anywhere anytime, no more worry on session outrage on Google Colab free tier.
🏭 Ready for integration & production: built on top of DocArray data structure, enjoy smooth integration with Jina, CLIP-as-service and other cross-/multi-modal applications.
Install
pip install discoart
If you are not using DiscoArt under Google Colab, then other dependencies might be required.
Get Started
Create artworks
from discoart import create
da = create()
That's it! It will create with the default text prompts and parameters.
Set prompts and parameters
Suppported parameters are listed here. You can specify them in create()
:
from discoart import create
da = create(text_prompts='A painting of sea cliffs in a tumultuous storm, Trending on ArtStation.',
init_image='https://d2vyhzeko0lke5.cloudfront.net/2f4f6dfa5a05e078469ebe57e77b72f0.png',
skip_steps=100)
This docs explains those parameters in very details. The minor difference on the parameters between DiscoArt and DD5.x is explained here.
Visualize results
create()
returns da
, a DocumentArray-type object. It contains the following information:
- All arguments passed to
create()
function, including seed, text prompts and model parameters. - The generated image and its intermediate images.
This allows you to further post-process, analyze, export the results with powerful DocArray API.
For example, you can display all final images in a grid:
da.plot_image_sprites(skip_empty=True, fig_size=(10, 10), show_index=True)
Note that all images perspective are preserved. You can display them one by one:
for d in da:
d.display()
The length of da
is determined by the n_batches
parameter.
You can take one particular run:
da[0].display()
Images are stored as Data URI in .uri
, to save it as a local file:
da[0].save_uri_to_file('discoart-result.png')
You can also zoom into a run and check out intermediate steps:
da[0].chunks.plot_image_sprites(skip_empty=True, fig_size=(10, 10), show_index=True)
You can .display()
the chunks one by one, or save one via .save_uri_to_file()
.
Finally, you can review its parameters via:
da[0].tags
Pull results anywhere anytime
If you are a free-tier Google Colab user, one annoy thing is the lost of sessions from time to time. Or sometimes you just early stop the run as the first image is not good enough, and a keyboard interrupt will prevent .create()
to return any result. Either case, you can easily recover the results by pulling the last session ID.
-
Find the session ID. It appears on top of the image.
-
Pull the result via that ID on any machine at any time, not necessarily on Google Colab:
from docarray import DocumentArray da = DocumentArray.pull('discoart-3205998582')
Reuse a Document as the initial state
One can use a Document as the initial state for the next run. Its .tags
will be used as the initial parameters; .uri
if presented will be used as the initial image.
from discoart import create
from docarray import DocumentArray
da = DocumentArray.pull('discoart-3205998582')
create(init_document=da[0], skip_steps=100)
Verbose logs
You can also get verbose logs by setting the following lines before import discoart
:
import os
os.environ['DISCOART_LOG_LEVEL'] = 'DEBUG'
Run in Docker
We provide a prebuilt Docker image for running DiscoArt in the Jupyter Notebook.
# docker build . -t jinaai/discoart # if you want to build yourself
docker run -p 51000:8888 -v $(pwd):/home/jovyan/ --gpus all jinaai/discoart
What's next?
😎 If you are already a DD user: you are ready to go! There is no extra learning, DiscoArt respects the same parameter semantics as DD5.2. So just unleash your creativity!
There are some differences between DiscoArt and DD5.x:
- DiscoArt does not support video generation and
image_prompt
(which was marked as ineffective in DD 5.2). - Due to no video support,
text_prompts
in DiscoArt accepts a string or a list of strings, not a dictionary; i.e. no frame index0:
or100:
. clip_models
accepts a list of values chosen fromViT-B/32
,ViT-B/16
,ViT-L/14
,RN101
,RN50
,RN50x4
,RN50x16
,RN50x64
. Slightly different in names vs. DD5.2.
👶 If you are a DALL·E Flow user: you may want to take step by step, as Disco Diffusion works in a very different way than DALL·E. It is much more advanced and powerful: e.g. Disco Diffusion can take weighted & structured text prompts; it can initialize from a image with controlled noise; and there are way more parameters one can tweak. Impatient prompt like "armchair avocado"
will give you nothing but confusion and frustration. I highly recommend you to check out the following resources before trying your own prompt:
- Zippy's Disco Diffusion Cheatsheet v0.3
- EZ Charts - Diffusion Parameter Studies
- Disco Diffusion 70+ Artist Studies
- A Traveler’s Guide to the Latent Space
Support
- Join our Slack community and chat with other community members about ideas.
- Join our Engineering All Hands meet-up to discuss your use case and learn Jina's new features.
- When? The second Tuesday of every month
- Where? Zoom (see our public events calendar/.ical) and live stream on YouTube
- Subscribe to the latest video tutorials on our YouTube channel
Join Us
DiscoArt is backed by Jina AI and licensed under MIT License. We are actively hiring AI engineers, solution engineers to build the next neural search ecosystem in open-source.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file discoart-0.0.15.dev6.tar.gz
.
File metadata
- Download URL: discoart-0.0.15.dev6.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a802879e9a23f49f5d7b55395eb7f4af1b5ed803f14d3792aeff685f3d76464 |
|
MD5 | d4331d898a2a3abb71c61dbb29a8dff2 |
|
BLAKE2b-256 | 96a2c4a53d8629ec2c9ff59fb7d2f7c6e8a39e6ba460eb25fa0a3d285d5dbe89 |