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.
create() with a Pythonic interface, autocompletion in IDE, and powerful features. Fetch real-time results anywhere anytime, no more worry on session outrage on Google Colab. Set initial state easily for more efficient parameter exploration.
pip install discoart
If you are not using DiscoArt under Google Colab, then other dependencies might be required.
from discoart import create da = create()
That's it! It will create with the default text prompts and parameters.
Suppported parameters are listed here. You can specify them in
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.
da, a DocumentArray-type object. It contains the following information:
create()function, including seed, text prompts and model parameters.
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, show_index=True, keep_aspect_ratio=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
You can take one particular run:
Images are stored as Data URI in
.uri, to save it as a local file:
You can also zoom into a run and check out intermediate steps:
da.chunks.plot_image_sprites(skip_empty=True, show_index=True, keep_aspect_ratio=True)
.display() the chunks one by one, or save one via
Finally, you can review its parameters via:
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.
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')
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, cut_ic_pow=0.5, tv_scale=600, cut_overview='*1000', cut_innercut='*1000', use_secondary_model=False)
You can also get verbose logs by setting the following lines before import
import os os.environ['DISCOART_LOG_LEVEL'] = 'DEBUG'
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
There are some minor differences between DiscoArt and DD5.x:
image_prompt(which was marked as ineffective in DD 5.2).
text_promptsin DiscoArt accepts a string or a list of strings, not a dictionary; i.e. no frame index
clip_modelsaccepts a list of values chosen from
RN50x64. Slightly different in names vs. DD5.2.
"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: