File size: 771 Bytes
ee22178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Progress reporting and scheduler selection shared with the standalone Gradio app."""


def set_scheduler(pipe, shift):
    pipe.scheduler = type(pipe.scheduler).from_config(pipe.scheduler.config, shift=shift)


def generate_with_progress(pipe, report_stage, report_step, **kwargs):
    progress_bar = pipe.progress_bar

    def progress(items):
        report_stage("denoise")
        for index, timestep in enumerate(progress_bar(items)):
            yield timestep
            report_step(pipe, index, timestep, {})
        if kwargs.get("output_type", "pil") != "latent":
            report_stage("decode")

    pipe.progress_bar = progress
    try:
        report_stage("encode")
        return pipe(**kwargs)
    finally:
        pipe.progress_bar = progress_bar