Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for Major Refactoring in v2.0.0 Branch #3

Draft
wants to merge 13 commits into
base: v2.0.0
Choose a base branch
from

Conversation

shunk031
Copy link

@shunk031 shunk031 commented Dec 29, 2024

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
Copy link
Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant