{"id":13708625,"url":"https://github.com/TissueImageAnalytics/cerberus","last_synced_at":"2025-05-06T13:31:25.347Z","repository":{"id":97659486,"uuid":"518545986","full_name":"TissueImageAnalytics/cerberus","owner":"TissueImageAnalytics","description":"One Model is All You Need: Multi-Task Learning Enables Simultaneous Histology Image Segmentation and Classification","archived":false,"fork":false,"pushed_at":"2024-11-27T19:43:47.000Z","size":222,"stargazers_count":83,"open_issues_count":5,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T20:01:47.377Z","etag":null,"topics":["computational-pathology","deep-learning","multi-task-learning","python","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TissueImageAnalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-27T17:07:19.000Z","updated_at":"2025-03-26T01:06:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"16ceb78e-fc25-4f62-8b74-83d36e47fdfa","html_url":"https://github.com/TissueImageAnalytics/cerberus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TissueImageAnalytics%2Fcerberus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TissueImageAnalytics%2Fcerberus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TissueImageAnalytics%2Fcerberus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TissueImageAnalytics%2Fcerberus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TissueImageAnalytics","download_url":"https://codeload.github.com/TissueImageAnalytics/cerberus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252693565,"owners_count":21789714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-pathology","deep-learning","multi-task-learning","python","pytorch"],"created_at":"2024-08-02T23:00:29.276Z","updated_at":"2025-05-06T13:31:25.341Z","avatar_url":"https://github.com/TissueImageAnalytics.png","language":"Python","funding_links":[],"categories":["Software"],"sub_categories":["Model"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"doc/cerberus.png\",\n  width=\"600\",\n  height=\"146\" \u003e\n\u003c/p\u003e\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-orange.svg)](https://www.gnu.org/licenses/gpl-3.0)\n  \u003ca href=\"#cite-this-repository\"\u003e\u003cimg src=\"https://img.shields.io/badge/Cite%20this%20repository-BibTeX-brightgreen\" alt=\"DOI\"\u003e\u003c/a\u003e \u003ca href=\"https://doi.org/10.1016/j.media.2022.102685\"\u003e\u003cimg src=\"https://img.shields.io/badge/DOI-10.1016%2Fj.media.2022.102685-blue\" alt=\"DOI\"\u003e\u003c/a\u003e\n\u003cbr\u003e\n\n\n# One Model is All You Need: Multi-Task Learning Enables Simultaneous Histology Image Segmentation and Classification \n\nThis repository contains code for using Cerberus, our multi-task model outlined in our [Medical Image Analysis paper](https://doi.org/10.1016/j.media.2022.102685).\n\nScroll down to the bottom to find instructions on downloading our [pretrained weights](#download-weights) and [WSI-level results](#download-tcga-results).\n\n## Set Up Environment\n\n```\n# create base conda environment\nconda env create -f environment.yml\n\n# activate environment\nconda activate cerberus\n\n# install PyTorch with pip\npip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html\n```\n\n## Repository Structure\n\nBelow we outline the contents of the directories in the repository.\n\n- `infer`: Inference scripts\n- `loader`: Data loading and post processing scripts\n- `misc`: Miscellaneous scripts and functions\n- `models`: Scripts relating to model definition and hyperparameters\n- `run_utils`: Model engine and callbacks\n\nThe purpose of the main scripts in the repository:\n\n- `run_infer_tile.py`: Run inference on image tiles\n- `run_infer_wsi.py`: Run inference on whole-slide images\n\n## Inference\n### Tiles\nTo process large image tiles, run:\n\n```\npython run_infer_tile.py --gpu=\u003cgpu_id\u003e --batch_size=\u003cn\u003e --model=\u003cpath\u003e --input_dir=\u003cpath\u003e --output_dir=\u003cpath\u003e \n```\n\nFor convenience, we have also included a bash script, where you can populate command line arguments. To make this script executable, run `chmod +x run_tile.sh`. Then use the command `./run_tile.sh`.\n\n### WSIs\nTo process whole-slide images, run:\n\n```\npython run_infer_wsi.py --gpu=\u003cgpu_id\u003e --batch_size=\u003cn\u003e --model=\u003cpath\u003e --input_dir=\u003cpath\u003e  mask_dir=\u003cpath\u003e --output_dir=\u003cpath\u003e \n```\n\nSimilar to the tile mode, we have included an example bash script (`run_wsi.sh`) that can be used to run the command, without having to always re-enter the arguments.\n\nFor both tile and WSI inference, the model path should point to a directory containing the settings file and the weights (`.tar` file). You will see from the above command that there is a `mask_dir` argument. In this repo, we assume that tissue masks have been automatically generated. You should include masks - otherwise it will lead to significantly longer processing times.\n\n## Download Weights\n\nIn this repository, we enable the download of:\n\n- Cerberus model for simultaneous:\n    - Gland instance segmentation \n    - Gland semantic segmentation (classification)\n    - Nuclear instance segmentation\n    - Nuclear semantic segmentation (classification)\n    - Lumen instance segmentation\n    - Tissue type patch classification\n- Pretrained ResNet weights (torchvision compatible) for transfer learning\n- Pretrained weights obtained from training each fold using:\n    - ImageNet weights and MTL\n    - ImageNet weights and MTL (with patch classification)\n\nDownload all of the above weights by visiting [this page](https://warwick.ac.uk/fac/cross_fac/tia/software/cerberus/).\n\nNote, the pretrained weights are designed for weight initialisation - not for model inference.\n  \nAll weights are under a non-commercial license. See the [License section](#license) for more details.\n\n## Download TCGA Results\n\nDownload results from processing 599 CRC WSIs using Cerberus at [this page](https://warwick.ac.uk/fac/cross_fac/tia/software/cerberus/).\n\n## License\n\nCode is under a GPL-3.0 license. See the [LICENSE](https://github.com/TissueImageAnalytics/cerberus/blob/master/LICENSE) file for further details.\n\nModel weights are licensed under [Attribution-NonCommercial-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-nc-sa/4.0/). Please consider the implications of using the weights under this license. \n\n## Cite this repository\n\n```\n@article{graham2022one,\n  title={One model is all you need: multi-task learning enables simultaneous histology image segmentation and classification},\n  author={Graham, Simon and Vu, Quoc Dang and Jahanifar, Mostafa and Raza, Shan E Ahmed and Minhas, Fayyaz and Snead, David and Rajpoot, Nasir},\n  journal={Medical Image Analysis},\n  pages={102685},\n  year={2022},\n  publisher={Elsevier}\n}\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTissueImageAnalytics%2Fcerberus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTissueImageAnalytics%2Fcerberus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTissueImageAnalytics%2Fcerberus/lists"}