Models Inconsistency
- TIA Toolbox version: 1.3.3
- Python version: 3.10.8
Description
Tiatoolbox has several pre-trained models helpful for data processing. However, models differ in how they handle input and output, making them confusing to use (especially when customizing):
- [ ] Activation functions apply at different steps for different models. Sometimes in
forwardmethod (e.g.CNNModel), sometimesforwardreturns a raw layer output and the transformation applies ininfer_batch(e.g.UNetModel). - [ ] Moreover, activation functions are hardcoded. To customize, you can't simply change an attribute; you must overwrite the whole method (different for each model).
- [ ] Data normalization distributes across methods:
HoVerNetuses it inforward,UNetModelin_transform,MicroNetinpreproc, and vanilla models rely on the user to do so. - [ ] Data preprocessing also lacks consistency. Even though it should happen in
preproc_func/_preprocfunctions,UNetModeluses its own_transform, unrelated to the standard methods. Yet, its behavior could implement in_preproc.
What to do
Refactoring the code will significantly improve readability:
- [ ] Decompose the pipeline into small granular methods in
ModelABC: one method for normalization, activation function as an attribute, etc. - [ ] Explain
ModelABCmethods in their documentation: doesinfer_batch relyonpostproc_func? Caninfer_batchbe used for training? How? - [ ] Reorganize custom model methods to match the new
ModelABCstructure. - [ ] Add a new page to the documentation explaining the Tiatoolbox models pipeline: how is it related to the PyTorch pipeline? How to evaluate a model? How to train a model?
I guess it will be fixed by #635
I have my own model ViT (vision transformer) I have trained my model and saved the best weight of the model, I want to run tia toolbox on my own data how can I use it my own model and weight of the model patches and WSI, please help me.
I have my own model ViT (vision transformer) I have trained my model and saved the best weight of the model, I want to run tia toolbox on my own data how can I use it my own model and weight of the model patches and WSI, please help me.
@Tamim1992 You can wrap your ViT into a format compatible with tiatoolbox like shown in this notebook: https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/examples/07-advanced-modeling.ipynb
Thank you for your response. The model performs well at the patch level, but when I apply it to overlay on my own data, the results aren't as good. Do you have any suggestions?