SlicerMorph / SlicerMEMOS

Mouse Embryo Multi-Organ Segmentations
BSD 2-Clause "Simplified" License
4 stars 3 forks source link

Run inference in a separate process #15

Closed lassoan closed 8 months ago

lassoan commented 8 months ago

It seems that inference is run inside the Slicer process: https://github.com/SlicerMorph/SlicerMEMOS/blob/4b30659ee57b2be49b58c99822e16a221b12c4d0/MEMOS/MEMOS.py#L245

Many things can go wrong during a complex and heavy computation task, so you want to isolate it from the application by running it in a separate process. That allows you to keep using the application while the computation is running, you can stop the process anytime (by killing the computation process), and you can prevent the application from crashing if the computation process is terminated (e.g., due to some errors in PyTorch or due to the operating system killing the process because of using too much resources).

You can use MONAIAuto3DSeg extension as an example. It launches auto3dseg_segresnet_inference.py script in a separate Python process.

Note that you would still use Slicer's Python environment, the only change would be that the inference is running in a separate process.

muratmaga commented 8 months ago

@smrolfe please implement this and also let's test the crash on JS2 with Andras's suggestion.

https://discourse.slicer.org/t/memos-new-extension-for-deep-learning-based-segmentation-of-3d-fetal-mice-scans/27956/32?u=muratmaga

muratmaga commented 8 months ago

addressed in https://github.com/SlicerMorph/SlicerMEMOS/commit/32e979400c5d04407e85460bea749c79e674b733