jina-ai / discoart

🪩 Create Disco Diffusion artworks in one line
Other
3.84k stars 249 forks source link

When using DISCOART_REMOTE_MODELS_URL, the first run fails on custom model #102

Closed entmike closed 2 years ago

entmike commented 2 years ago

DISCOART_REMOTE_MODELS_URL=https://www.feverdreams.app/models.yaml

If I select portrait_generator_v1.5_ema_0.9999_165000 as my diffusion model, the first job will fail with this error. (In either straight Python or NB cell)

app_1      |   File "/usr/local/lib/python3.8/dist-packages/discoart/create.py", line 199, in create
app_1      |     model, diffusion = load_diffusion_model(_args, device=device)
app_1      |   File "/usr/local/lib/python3.8/dist-packages/discoart/helper.py", line 407, in load_diffusion_model
app_1      |     download_model(diffusion_model)
app_1      |   File "/usr/local/lib/python3.8/dist-packages/discoart/helper.py", line 304, in download_model
app_1      |     raise ValueError(
app_1      | ValueError: None is not supported, must be one of dict_keys(['256x256_diffusion_uncond', '512x512_diffusion_uncond_finetune_008100', 'PulpSciFiDiffusion', 'pixel_art_diffusion_hard_256', 'pixel_art_diffusion_soft_256', 'pixelartdiffusion4k', 'PADexpanded', 'secondary', 'watercolordiffusion', 'watercolordiffusion_2', '256x256_openai_comics_faces_v2.by_alex_spirin_114k', 'portrait_generator_v001_ema_0.9999_1MM', 'FeiArt_Handpainted_CG_Diffusion', 'Ukiyo-e_Diffusion_All_V1.by_thegenerativegeneration', 'IsometricDiffusionRevrart512px'])

However if I run the same cell again (or loop in the case of a Python case), the 2nd attempt will work.

hanxiao commented 2 years ago

This is because downloading of the remote models is put into a separate thread to avoid the main thread to be blocked by the network (though normally very small, but for an env with bad/no network, this lag is significant).

To make sure remote download list always happens first, you can do the following code manually

from discoart.helper import models_list, get_remote_model_list

get_remote_model_list(model_list, force_print=False)

from discoart import create

create(..., diffusion_model='customized-blah-blah')

then you will find model_list is up to date and create just works without any problem