neuronets / nobrainer

A framework for developing neural network models for 3D image processing.
Other
159 stars 45 forks source link

Add feature to list available models in Segmentation #303

Closed hvgazula closed 8 months ago

hvgazula commented 8 months ago

It will be a class method list_available_methods(self).

hvgazula commented 8 months ago

Added a class method list_available_models() to Segmentation. However, the problem with this fix is, a model has to be loaded first. For example-

from nobrainer.processing import Segmentation
from nobrainer.models import unet

test1 = Segmentation()   # fails because needs a `base_model` to initialize
model = unet  # "unet"
test2 = Segmentation(model)  # will work fine

test1.list_available_models()  # will not work
test2.list_available_models()  # will work

A more cleaner way to do things will be

test = Segmentation()
test.list_available_models()
test.add_model("unet")  # or `load_model`

In short, need to rewriteSegmentation.__init__() to reconcile both test = Segmentation() and test = Segmentation(model) such that the class method will work no matter what.

hvgazula commented 8 months ago

Fixed.

satra commented 8 months ago

one can have a classmethod instead of just a method, so init does not need to be called. see the base class for some example classmethods.