2

discoart.ipynb - Colaboratory

 1 year ago
source link: https://colab.research.google.com/github/jina-ai/discoart/blob/main/discoart.ipynb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

discoart.ipynb - Colaboratory

discoart.ipynb_ Rename notebook
Insert
Runtime
Tools
Share
Code Text Copy to Drive
Create Disco Diffusion artworks in one-line

😎 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! Read more about DiscoArt vs. DD5.5

You can always do from discoart import cheatsheet; cheatsheet() to check all new/modified parameters, DiscoArt specific parameters are highlighted in the cheatsheet.

👶 If you are a DALL·E Flow or new 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:

Install

!pip install -U discoart

Create artworks

from discoart import create

da = create()

That's it. It is that simple.

Specify parameters

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)

Check parameter cheatsheet

But what parameters can be used in create()? just type cheatsheet() to lookup anytime:

from discoart import cheatsheet

cheatsheet()

🎉 That's all you need to learn.

Of course if you have some extra time, it would be helpful for you to learn the following API of DiscoArt.


Visualize results

Final results and intermediate results are created under the current working directory, e.g.

./{name-docarray}/{i}-step-{j}.png
./{name-docarray}/{i}-progress.png
./{name-docarray}/{i}-progress.gif
./{name-docarray}/{i}-done.png
result-persist.png?raw=1

where:

  • name-docarray is the name of the run, you can specify it otherwise it is a random name.
  • i-* is up to the value of n_batches.
  • *-done-* is the final image on done.
  • *-step-* is the intermediate image at certain step.
  • *-progress.png is the sprite image of all intermediate results so far.
  • *-progress.gif is the animated gif of all intermediate results so far.

The save frequency is controlled by save_rate.

Export configs

You can review its parameters from da[0].tags or export it as an SVG image:

from discoart.config import save_config_svg

save_config_svg(da, 'my.svg')

Pull results anywhere anytime

At anytime on any machine, you can pull the real-time results (including paramters, intermedidate diffusion steps, final results) with a session ID:

Please replace discoart-3205998582 to your own when you run the above 2 cells!

from docarray import DocumentArray

da = DocumentArray.pull('discoart-3205998582')

Reuse a Document as initial state

Consider a Document as a self-contained data with config and image, one can use it as the initial state for the future 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],
       cut_ic_pow=0.5,
       tv_scale=600, 
       cut_overview='[12]*1000', 
       cut_innercut='[12]*1000', 
       use_secondary_model=False)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK