-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(gui): run inference in a separate process and temporarily disable button #279
Conversation
Wouldn't it be better to throw the whole thing to the pool? |
I've tried doing that just now but it seems I can't update the window variable properly this way... Apparently the function is just... never called at all. I added a def enable_infer_button(window: sg.Window):
window["infer"].update(disabled=False) Further down in the event handling: LOG.info("Starting inference...")
window["infer"].update(disabled=True)
pool.schedule(
infer,
kwargs=dict(
# # window
# window=window,
# paths
model_path=Path(values["model_path"]),
output_path=output_path,
input_path=input_path,
config_path=Path(values["config_path"]),
# svc config
speaker=values["speaker"],
cluster_model_path=Path(values["cluster_model_path"])
if values["cluster_model_path"]
else None,
transpose=values["transpose"],
auto_predict_f0=values["auto_predict_f0"],
cluster_infer_ratio=values["cluster_infer_ratio"],
noise_scale=values["noise_scale"],
f0_method=values["f0_method"],
# slice config
db_thresh=values["silence_threshold"],
pad_seconds=values["pad_seconds"],
chunk_seconds=values["chunk_seconds"],
absolute_thresh=values["absolute_thresh"],
device="cpu" if not values["use_gpu"] else get_optimal_device(),
)
)
pool.schedule(
enable_infer_button,
args=[window]
)
if values["auto_play"]:
pool.schedule(play_audio, args=[output_path]) |
I meant that there would be no particular need to disable the button... what do you think? |
Okay so I moved the function around, maybe it was because I was lacking 2 newlines inbetween, and now it's working properly with the pool. I've also noticed ThreadPool is faster than ProcessPool.
Well, in theory there isn't, no. However, I think it might be a good visual indicator for the user to know that something is still going on. If we don't disable the button, and instead just schedule further inferences afterwards, the user has to wait until the first inference is done until it get's to the next one. |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #279 +/- ##
==========================================
- Coverage 20.51% 20.39% -0.12%
==========================================
Files 38 38
Lines 3247 3280 +33
Branches 417 425 +8
==========================================
+ Hits 666 669 +3
- Misses 2564 2593 +29
- Partials 17 18 +1
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I think this change will cause 3 tasks to run at the same time and not work properly. |
Which tasks in particular? Unless you mean different tasks? |
I reverted back to However, apparently now it doesn't want to schedule the |
Alright, managed to fix that by utilizing the future's I'll test it a bit further and once I feel it's ready I'll merge all commits into a single one so it's better for a potential merge. |
Is this now complete? Can it be merged? |
It should be complete, yes, but I can do one last test once I'm back home in around 2 hours if you'd like me to. |
677fff5
to
c6965c2
Compare
This PR will change the "Infer" button to run in a thread utilizing PySimpleGui's
window.start_thread
method.While this is going on, the "Infer" button will be disabled until inference is completed (or fails due to an exception)
This will prevent the GUI from freezing up and will allow the user to already prepare the settings for the next inference
Added another commit fixing the "Infer" button from disabling a bit too late, potentially making it possible to quickly run it multiple times in a row (e.g. spam clicking)