uhlmanngroup / splinedist

SplineDist: Automated Cell Segmentation with Spline Curves
BSD 3-Clause "New" or "Revised" License
65 stars 15 forks source link

Trained model for inference #10

Closed JulesScholler closed 1 year ago

JulesScholler commented 2 years ago

Hello,

I wanted to give a try to SplineDist but couldn't find any pre-trained model. I try to load up a pre-trained stardist model but got the following output error:

Traceback (most recent call last):
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3378, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-42fa6c79fe7d>", line 1, in <module>
    runfile('/home/jules/PycharmProjects/PBM_2D/segment_gfap.py', wdir='/home/jules/PycharmProjects/PBM_2D')
  File "/snap/pycharm-professional/300/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "/snap/pycharm-professional/300/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/jules/PycharmProjects/PBM_2D/segment_gfap.py", line 9, in <module>
    model = SplineDist2D(None, name='2D_versatile_fluo', basedir='/home/jules/.keras/models/StarDist2D')
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/splinedist/models/model2d.py", line 260, in __init__
    super().__init__(config, name=name, basedir=basedir)
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/splinedist/models/base.py", line 274, in __init__
    super().__init__(config=config, name=name, basedir=basedir)
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/csbdeep/models/base_model.py", line 106, in __init__
    self._set_logdir()
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/csbdeep/models/base_model.py", line 32, in wrapper
    return f(*args, **kwargs)
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/csbdeep/models/base_model.py", line 141, in _set_logdir
    self.config = self._config_class(**config_dict)
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/splinedist/models/model2d.py", line 222, in __init__
    self.update_parameters(False, **kwargs)
  File "/home/jules/miniconda3/envs/stardist/lib/python3.10/site-packages/csbdeep/models/config.py", line 74, in update_parameters
    raise AttributeError("Not allowed to add new parameters (%s)" % ', '.join(attr_new))
AttributeError: Not allowed to add new parameters (n_rays)

Do I need to train a model to test SplineDist or where can I find a pre-trained model?

Thanks for your help.

sohmandal commented 2 years ago

Hi @JulesScholler, you can find some pretrained SplineDist models here.

If you have a dataset that these pretrained models do not work out for, please feel free to let us know. We might be able to provide a tailored trained model for your dataset.

Hope this helps.

JulesScholler commented 2 years ago

Thanks a lot. I was able to use the pre-trained weights but it's not working great. I guess it was trained on nucleus and my images are really different:

image

I might try to re-trained with annotated data, I will let you know!

sohmandal commented 2 years ago

Hi @JulesScholler, you are absolutely right. Those models are trained on nuclei dataset. So for an image as the one attached with your reply, those models would not be able to perform very well. Retraining SplineDist with annotated data would definitely be helpful.

sohmandal commented 1 year ago

Closing this issue now because of inactivity. Please feel free to reopen it.