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

Add progress_update hook to do_run #159

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

entmike
Copy link

@entmike entmike commented Aug 9, 2022

Proposed addition of progress_update hook mentioned here #157.

Sample test script:

import sys, os, multiprocessing
from types import SimpleNamespace

def pcb(progress):
    print(progress)


def mutate(**kwargs):
    from discoart import runner
    from discoart.config import (
        load_config,
        print_args_table
    )
    from discoart.helper import (
        load_diffusion_model,
        load_clip_models,
        load_secondary_model,
        get_device,
        free_memory,
        show_result_summary,
        get_output_dir,
    )
    events = tuple(
        kwargs.pop(v, multiprocessing.Event()) or multiprocessing.Event()
        for v in ('skip_event', 'stop_event')
    )
    _clip_models_cache = {}
    _args = load_config(user_config=kwargs)
    print_args_table(_args)
    _args = SimpleNamespace(**_args)
    
    device = get_device()
    model, diffusion = load_diffusion_model(_args, device=device)

    clip_models = load_clip_models(
        device,
        enabled=_args.clip_models,
        clip_models=_clip_models_cache,
        text_clip_on_cpu=_args.text_clip_on_cpu,
    )
    secondary_model = load_secondary_model(_args, device=device)

    free_memory()
    is_exit0 = False
    runner.do_run(
        _args,
        (model, diffusion, clip_models, secondary_model),
        device=device,
        events=events,
        progress_callback = pcb
    )

mutate()

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 this pull request may close these issues.

1 participant