Discoart
🪩 Create Disco Diffusion artworks in one line
Install / Use
/learn @jina-ai/DiscoartREADME

DiscoArt is an elegant way of creating compelling Disco Diffusion<sup><a href="#example-application">[*]</a></sup> 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.
<sub><sup><a id="example-application">[*]</a> Disco Diffusion is a Google Colab Notebook that leverages CLIP-Guided Diffusion to allow one to create compelling and beautiful images from text prompts. </sup></sub>
💯 Best-in-class: industry-level engineering, top-notch code quality, lean dependencies, small RAM/VRAM footprint; important bug fixes, feature improvements vs. the original DD5.6.
👼 Available to all: smooth install for self-hosting, Google Colab free tier, non-GUI (IPython) environment, and CLI! No brainfuck, no dependency hell, no stackoverflow.
🎨 Focus on create not code: one-liner 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.
🏭 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.
☁️ As-a-service: simply python -m discoart serve, DiscoArt is now a high-performance low-latency service supports gRPC/HTTP/websockets and TLS. Scaling up/down is one-line; Cloud-native features e.g. Kubernetes, Prometheus and Grafana is one-line. Unbelievable simple thanks to Jina.
Gallery with prompts
Do you see the discoart-id in each tweet? To get the config & prompts, simply:
from discoart import show_config
show_config('discoart-id')
Install
Python 3.7+ and CUDA-enabled PyTorch is required.
pip install discoart
This applies to both self-hosting, Google Colab, system integration, non-GUI environments.
- Self-hosted Jupyter: to run a Jupyter Notebook on your own GPU machine, the easiest way is to use our prebuilt Docker image.
- Use it from CLI:
python -m discoart createandpython -m discoart configare CLI commands. - Use it as a service:
python -m discoart serveallows one to run it as gRPC/HTTP/websockets service.
GUI
DiscoArt is the infrastructure for creating Disco Diffusion artworks. The built-in Jupyter Notebook support gives you basic yet limited user experience, e.g. it does not offer any intuitive GUI for prompt scheduling. Note that DiscoArt is developer-centric and API-first, hence improving consumer-facing experience is out of the scope. There are services, platforms and products (not Jina AI affiliated) that already integrate DiscoArt as a service and provide nice GUI on top of it, e.g. Fever Dreams, Replicate, RunPod and Renderflux.
<details> <summary>Click to see third-party GUI</summary>- Fever Dreams: a free community-powered service with nice GUI and gallery, where people generate and share their DiscoArt artworks, prompts and configs.
- Replicate: a free form-based GUI of DiscoArt with sandbox user experience and the visualizations.
- RunPod: a paid GPU cloud provider that runs DiscoArt container with a simple and clean GUI to visualize the configs and creations.
- Renderflux: a paid creative art platform that wraps DiscoArt and provides end-to-end GUI for creation management.
Please be aware that these platforms, products or companies are not affiliated with Jina AI. They define their own terms of services, paywall and data and privacy policies, which are not in the scope of DiscoArt MIT License.
</details>Get Started
<a href="https://colab.research.google.com/github/jina-ai/discoart/blob/main/discoart.ipynb"><img src="https://img.shields.io/badge/Open-in%20Colab-brightgreen?logo=google-colab&style=flat-square" alt="Open in Google Colab"/></a>
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
Supported 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,
)

In case you forgot a parameter, just lookup the cheatsheet at anytime:
from discoart import cheatsheet
cheatsheet()
The difference on the parameters between DiscoArt and DD5.6 is explained here.
Visualize results
Final results and intermediate results are created under the current working directory, i.e.
./{name-docarray}/{i}-done.png
./{name-docarray}/{i}-step-{j}.png
./{name-docarray}/{i}-progress.png
./{name-docarray}/{i}-progress.gif
./{name-docarray}/da.protobuf.lz4

where:
name-docarrayis the name of the run, you can specify it otherwise it is a random name.i-*is up to the value ofn_batches.*-done-*is the final image on done.*-step-*is the intermediate image at certain step, updated in real-time.*-progress.pngis the sprite image of all intermediate results so far, updated in real-time.*-progress.gifis the animated gif of all intermediate results so far, updated in real-time.da.protobuf.lz4is the compressed protobuf of all intermediate results so far, updated in real-time.
The save frequency is controlled by save_rate.
Moreover, 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. - 4 generated image and its intermediate steps' images, where
4is determined byn_batchesand is the default value.
This allows you to further post-process, analyze, export the results with powerful DocArray API.
Images are stored as Data URI in .uri, to save the first image as a local file:
da[0].save_uri_to_file('discoart-result.png')
To save all final images:
for idx, d in enumerate(da):
d.save_uri_to_file(f'discoart-result-{idx}.png')
You can also display all four final images in a grid:
da.plot_image_sprites(skip_empty=True, show_index=True, keep_aspect_ratio=True)

Or display them one by one:
for d in da:
d.display()
Or take one particular run:
da[0].display()

Visualize intermediate steps
You can also zoom into a run (say the first run) and check out intermediate steps:
da[0].chunks.plot_image_sprites(
skip_empty=True, show_index=True, keep_aspect_ratio=True
)

You can .display() the chunks one by one, or save one via .save_uri_to_file(), or save all intermediate steps as a GIF:
da[0].chunks.save_gif(
'lighthouse.gif', show_index=True, inline_display=True, size_ratio=0.5
)

Note that >=0.7.14, a 20FPS gif is generated which includes all intermedidate steps.
Show/save/load configs
To show the config of a Document/DocumentArray,
from discoart import show_config
show_config(da) # show the config of the first run
show_config(da[3]) # show the config of the fourth run
show_config(
'discoart-06030a0198843332edc554ffebfbf288'
) # show the config of the run with a known DocArray ID
To save the config of a Document/DocumentArray,
from discoart import save_config
save_config(da, 'my.yml') # save the config of the first run
save_config(da[3], 'my.yml') # save the config of the fourth run
To run create from a YAML config of Document/DocumentArray,
from discoart import create, load_config
config = load_config('my.yml')
create(**config)
You can also export the config as an SVG image:
from discoart.config import save_config_svg
save_config_svg
