Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to Disable/Control Progress Bars (TQDM)? #137

Closed
kevinjdolan opened this issue Aug 4, 2022 · 4 comments · Fixed by #138
Closed

Possible to Disable/Control Progress Bars (TQDM)? #137

kevinjdolan opened this issue Aug 4, 2022 · 4 comments · Fixed by #138

Comments

@kevinjdolan
Copy link

I was trying to search through the code to figure out where the progress bars are being generated, but I could not locate them. I assume they are being powered by TQDM.

I am getting frustrating output when the logs are output to a file in the context of a Docker container running on Kubernetes. I would like to either remove the TQDM rendering altogether, or modify so that it is not producing the input characters intended for a live console.

Is there a documented way to control the TQDM rendering? If not, can you point me in the right direction for how to control these?

@kevinjdolan
Copy link
Author

I was able to disable the progress produced by the guided-diffusion library through a monkey-patched hack:

def _disable_progress():
    from guided_diffusion.gaussian_diffusion import GaussianDiffusion
    orig_ddim = GaussianDiffusion.ddim_sample_loop_progressive
    orig_plms = GaussianDiffusion.plms_sample_loop_progressive
    def new_ddim(*args, **kwargs):
        kwargs['progress'] = False
        return orig_ddim(*args, **kwargs)
    def new_plms(*args, **kwargs):
        kwargs['progress'] = False
        return orig_plms(*args, **kwargs)
    GaussianDiffusion.ddim_sample_loop_progressive = new_ddim
    GaussianDiffusion.plms_sample_loop_progressive = new_plms

This succeeds at removing the progress bars.

A cleaner way would be to accept an environment variable, perhaps here:

runner.py#373

        show_progress = not os.environ.get('DISCOART_DISABLE_PROGRESS')
        if args.diffusion_sampling_mode == 'ddim':
            samples = sample_fn(
                model,
                (args.batch_size, 3, side_y, side_x),
                clip_denoised=args.clip_denoised,
                model_kwargs={},
                cond_fn=cond_fn,
                progress=show_progress,
                skip_timesteps=skip_steps,
                init_image=init,
                randomize_class=args.randomize_class,
                eta=args.eta,
                transformation_fn=lambda x: symmetry_transformation_fn(
                    x, args.use_horizontal_symmetry, args.use_vertical_symmetry
                ),
                transformation_percent=args.transformation_percent,
            )
        else:
            samples = sample_fn(
                model,
                (args.batch_size, 3, side_y, side_x),
                clip_denoised=args.clip_denoised,
                model_kwargs={},
                cond_fn=cond_fn,
                progress=show_progress,
                skip_timesteps=skip_steps,
                init_image=init,
                randomize_class=args.randomize_class,
                order=2,
            )

Apparently this does not solve my problem, however! I am seeing a lot of newlines being generated but I am not sure where they are coming from, and this is not an issue when I am running it interactively. Odd behavior!

@kevinjdolan
Copy link
Author

For reference, this is the output in the logging file that I am seeing:

                   discoart-8bdf8c8e141c11edb869751f290d0983
╭────────────────────────────┬─────────────────────────────────────────────────╮
│                   Argument │ Value                                           │
├────────────────────────────┼─────────────────────────────────────────────────┤
│                 batch_name │ None                                            │
│                batch_size* │ 4                                               │
│                 clamp_grad │ True                                            │
│                  clamp_max │ 0.05                                            │
│              clip_denoised │ False                                           │
│       clip_guidance_scale* │ 524.288                                         │
│                clip_models │ ['ViT-B-32::openai', 'ViT-B-16::openai',        │
│                            │ 'RN50::openai']                                 │
│      clip_models_schedules │ None                                            │
│                cut_ic_pow* │ [1.0]*800+[4.0]*200                             │
│               cut_icgray_p │ [0.2]*400+[0]*600                               │
│              cut_innercut* │ [16]*400+[48]*600                               │
│              cut_overview* │ [48]*400+[16]*600                               │
│        cut_schedules_group │ None                                            │
│              cutn_batches* │ 1                                               │
│            diffusion_model │ 512x512_diffusion_uncond_finetune_008100        │
│     diffusion_model_config │ None                                            │
│    diffusion_sampling_mode │ ddim                                            │
│               display_rate │ None                                            │
│                        eta │ 0.8                                             │
│                    gif_fps │ 20                                              │
│             gif_size_ratio │ 0.5                                             │
│                 init_image │ None                                            │
│                 init_scale │ 1000                                            │
│                 n_batches* │ 1                                               │
│             name_docarray* │ discoart-8bdf8c8e141c11edb869751f290d0983       │
│        on_misspelled_token │ ignore                                          │
│                perlin_init │ False                                           │
│                perlin_mode │ mixed                                           │
│                   rand_mag │ 0.05                                            │
│            randomize_class │ True                                            │
│               range_scale* │ 250                                             │
│                  sat_scale │ 0                                               │
│                 save_rate* │ 10                                              │
│                      seed* │ 3605636296                                      │
│                  skip_augs │ False                                           │
│                 skip_event │ None                                            │
│                 skip_steps │ 0                                               │
│                     steps* │ 100                                             │
│                 stop_event │ None                                            │
│           text_clip_on_cpu │ False                                           │
│              text_prompts* │ ['Overheard at the Orchard', 'Sven Nordqvist    │
│                            │ Illustration']                                  │
│     transformation_percent │ [0.09]                                          │
│ truncate_overlength_prompt │ False                                           │
│                   tv_scale │ 0                                               │
│    use_horizontal_symmetry │ False                                           │
│        use_secondary_model │ True                                            │
│      use_vertical_symmetry │ False                                           │
│              width_height* │ [512, 512]                                      │
╰────────────────────────────┴─────────────────────────────────────────────────╯
                 showing all args (bold * args are non-default)
Loading diffusion model 512x512_diffusion_uncond_finetune_008100...
Found model disco-diffusion/512x512_diffusion_uncond_finetune_008100 in local cache!
...done in 0.00s: (Loading diffusion model 512x512_diffusion_uncond_finetune_008100)
Augmenting disco cache path to: /cache/models/disco-diffusion/512x512_diffusion_uncond_finetune_008100
Loading diffusion model secondary...
Found model disco-diffusion/secondary in local cache!
...done in 0.00s: (Loading diffusion model secondary)
Augmenting disco cache path to: /cache/models/disco-diffusion/secondary
2022-08-04 17:40:49,826 - discoart - INFO - preparing models...
Setting up [LPIPS] perceptual loss: trunk [vgg], v[0.1], spatial [off]
Loading model from: /usr/local/lib/python3.10/site-packages/lpips/weights/v0.1/vgg.pth
2022-08-04 17:40:51,561 - discoart - INFO - creating artworks `discoart-8bdf8c8e141c11edb869751f290d0983` (0/1)...










































































































2022-08-04 17:43:58,149 - discoart - INFO - done! discoart-8bdf8c8e141c11edb869751f290d0983

@entmike
Copy link

entmike commented Aug 4, 2022

Yes it would be great to kill the TQDM/progress bar stuff for integration use cases.

@hanxiao
Copy link
Member

hanxiao commented Aug 4, 2022

from 0.11.2 set env DISCOART_DISABLE_TQDM=1

btw, we are K8s and cloud-native expert, more expert than diffusion 😉 , if you encounter any problem when deploying DiscoArt in production env such as K8s, please let us know @kevinjdolan

FYI @jina-ai/engineering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants