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

How to implement process_relight concurrent calls? #119

Open
isgbuddy opened this issue Dec 27, 2024 · 0 comments
Open

How to implement process_relight concurrent calls? #119

isgbuddy opened this issue Dec 27, 2024 · 0 comments

Comments

@isgbuddy
Copy link

isgbuddy commented Dec 27, 2024

executor = ThreadPoolExecutor()

    # 异步调用 process_relight 函数
    processed_fg, results = await async_process_relight(
        input_fg=input_fg,
        prompt=prompt,
        image_width=image_width,
        image_height=image_height,
        num_samples=num_samples,
        seed=seed,
        steps=steps,
        a_prompt=a_prompt,
        n_prompt=n_prompt,
        cfg=cfg,
        highres_scale=highres_scale,
        highres_denoise=highres_denoise,
        lowres_denoise=lowres_denoise,
        bg_source=bg_source
    )
   async def async_process_relight(input_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg,
                            highres_scale, highres_denoise, lowres_denoise, bg_source):
loop = asyncio.get_event_loop()
# 使用 *args 传递位置参数,而不是关键字参数
return await loop.run_in_executor(
    executor,
    process_relight,
    input_fg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg,
    highres_scale, highres_denoise, lowres_denoise, bg_source
)

These codes can do async call process_relight ok. But don't create result image at the same time.

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

No branches or pull requests

1 participant