Skip to content

Commit

Permalink
Added inference notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodore Zhao committed Dec 4, 2024
1 parent 6fa21ec commit 3634dc4
Show file tree
Hide file tree
Showing 6 changed files with 955 additions and 54 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This repository hosts the code and resources for the paper **"A Foundation Model
![Example Predictions](assets/readmes/biomedparse_prediction_examples.png)

## News
- Dec. 3, 2024: We added inference notebook examples in inference_example_RGB.ipynb and inference_example_NIFTI.ipynb
- Nov. 22, 2024: We added negative prediction p-value example in inference_example_DICOM.ipynb
- Nov. 18, 2024: BiomedParse is officially online in [*Nature Methods*](https://aka.ms/biomedparse-paper)!

Expand Down
Binary file added examples/amos_0328.nii.gz
Binary file not shown.
89 changes: 38 additions & 51 deletions inference_examples_DICOM.ipynb

Large diffs are not rendered by default.

373 changes: 373 additions & 0 deletions inference_examples_NIFTI.ipynb

Large diffs are not rendered by default.

540 changes: 540 additions & 0 deletions inference_examples_RGB.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions modeling/BaseModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def forward(self, *inputs, **kwargs):
def save_pretrained(self, save_dir):
torch.save(self.model.state_dict(), os.path.join(save_dir, "model_state_dict.pt"))

def from_pretrained(self, pretrained,
def from_pretrained(self, pretrained, filename: str = "biomedparse_v1.pt",
local_dir: str = "./pretrained", config_dir: str = "./configs"):
if pretrained.startswith("hf_hub:"):
hub_name = pretrained.split(":")[1]
huggingface_hub.hf_hub_download(hub_name, filename="biomedparse_v1.pt",
huggingface_hub.hf_hub_download(hub_name, filename=filename,
local_dir=local_dir)
huggingface_hub.hf_hub_download(hub_name, filename="config.yaml",
local_dir=config_dir)
load_dir = os.path.join(local_dir, "biomedparse_v1.pt")
load_dir = os.path.join(local_dir, filename)
else:
load_dir = pretrained

Expand Down

0 comments on commit 3634dc4

Please sign in to comment.