OpenMAP-T1 icon indicating copy to clipboard operation
OpenMAP-T1 copied to clipboard

Proposal for Major Refactoring in v2.0.0 Branch

Open shunk031 opened this issue 1 year ago • 1 comments

Thank you for releasing this amazing project. I have conducted a significant refactoring for the v2.0.0 branch, which allows parcellation using OpenMAT-T1 to be executed as follows:

How to Run

Firstly, install the library from this repository via pip:

pip install git+https://github.com/OishiLab/[email protected]

Then, you can execute parcellation with the following command (I hope this remains mostly consistent with the original options). Please ensure that you have transformed the models as shown below beforehand.

openmap-t1 parcellation --input-folder data/NFBS_Dataset --output-folder outputs

Major improvements

Improved Loading of Pre-trained Models

Following the interface of transformers, you can now load pre-trained models as follows:

from openmap_t1.models.unet import UNet

cnet = UNet.from_pretrained("OishiLab/OpenMAP-T1/CNet")

cnet.push_to_hub("OishiLab/OpenMAP-T1", subfolder="CNet") # If you push to hf hub

How to achieve the loading process

To enable the above functionality, you need to transform the pre-trained models to be compatible with transformers. First, clone this PR branch:

git clone -b v2.0.0 https://github.com/OishiLab/OpenMAP-T1

Set up the environment using uv:

uv sync

Place the pre-trained models in the following structure:

├── data
│    └── OpenMAP-T1-V2.0.0
│          ├── CNet
│          ├── HNet
│          ├── PNet
│          └── SSNet
├── level
├── media
├── src
│    └── openmap_t1
│        ├── commands
│        ├── models
│        │    └── unet
│        └── utils
└── tests

Execute the following command. After execution, the transformation results for each model will be located under ./OishiLab/OpenMAP-T1/:

uv run pytest -vsx tests/load_pretrained_model_test.py

shunk031 avatar Dec 29 '24 13:12 shunk031

@kei-lab1106 I have set this PR as a draft. Once all work is completed, could you please review it? Your feedback would be greatly appreciated!

shunk031 avatar Dec 29 '24 13:12 shunk031