Skip to content

Commit

Permalink
Fix lightning issue (#41)
Browse files Browse the repository at this point in the history
* Fix model loading issue with new lightning versions

* Adjust code style

* Adjust to precommit style

* add download link for MONAI v1.3.0 model

* add troubleshooting section
  • Loading branch information
LorenzLamm authored Nov 1, 2023
1 parent c132a79 commit 67417a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ This should display the different options you can choose from MemBrain, like "se

## Step 5: Download pre-trained segmentation model (optional)
We recommend to use denoised (ideally Cryo-CARE<sup>1</sup>) tomograms for segmentation. However, our current best model is available for download [here](https://drive.google.com/file/d/1tSQIz_UCsQZNfyHg0RxD-4meFgolszo8/view?usp=sharing) and should also work on non-denoised data. Please let us know how it works for you.

NOTE: Previous model files are not compatible with MONAI v1.3.0 or higher. So if you're using v1.3.0 or higher, consider downgrading to MONAI v1.2.0 or downloading this [adapted version](https://drive.google.com/file/d/1Tfg2Ju-cgSj_71_b1gVMnjqNYea7L1Hm/view?usp=sharing) of our most recent model file.

If the given model does not work properly, you may want to try one of our previous versions:

Other (older) model versions:
Expand All @@ -65,3 +68,16 @@ Once downloaded, you can use it in MemBrain-seg's [Segmentation](./Usage/Segment
```
[1] T. -O. Buchholz, M. Jordan, G. Pigino and F. Jug, "Cryo-CARE: Content-Aware Image Restoration for Cryo-Transmission Electron Microscopy Data," 2019 IEEE 16th International Symposium on Biomedical Imaging (ISBI 2019), Venice, Italy, 2019, pp. 502-506, doi: 10.1109/ISBI.2019.8759519.
```


# Troubleshooting
Here is a collection of common issues and how to fix them:

- `RuntimeError: The NVIDIA driver on your system is too old (found version 11070). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has
been compiled with your version of the CUDA driver.`

The latest Pytorch versions require higher CUDA versions that may not be installed on your system yet. You can either install the new CUDA version or (maybe easier) downgrade Pytorch to a version that is compatible:

`pip uninstall torch`

`pip install torch==2.0.1`
5 changes: 3 additions & 2 deletions src/membrain_seg/segmentation/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ def segment(
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# Initialize the model and load trained weights from checkpoint
pl_model = SemanticSegmentationUnet()
pl_model = pl_model.load_from_checkpoint(model_checkpoint, map_location=device)
pl_model = SemanticSegmentationUnet.load_from_checkpoint(
model_checkpoint, map_location=device, strict=False
)
pl_model.to(device)

# Preprocess the new data
Expand Down

0 comments on commit 67417a4

Please sign in to comment.