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

Fix Imports in Livecell Inference #219

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/finetuned_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ See for example the [2d annotator example](https://github.com/computational-cell

As a rule of thumb:
- Use the `_lm` models for segmenting cells or nuclei in light microscopy.
- Use the `_em` models for segmenting ceells or neurites in electron microscopy.
- Note that this model does not work well for segmenting mitochondria or other organelles becuase it is biased towards segmenting the full cell / cellular compartment.
- Use the `_em` models for segmenting cells or neurites in electron microscopy.
- Note that this model does not work well for segmenting mitochondria or other organelles because it is biased towards segmenting the full cell / cellular compartment.
- For other cases use the default models.

See also the figures above for examples where the finetuned models work better than the vanilla models.
Expand Down
4 changes: 2 additions & 2 deletions doc/python_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import micro_sam
```

The library
- implements function to apply Segment Anything to 2d and 3d data more conviently in `micro_sam.prompt_based_segmentation`.
- provides more and imporoved automatic instance segmentation functionality in `micro_sam.instance_segmentation`.
- implements function to apply Segment Anything to 2d and 3d data more conveniently in `micro_sam.prompt_based_segmentation`.
- provides more and improved automatic instance segmentation functionality in `micro_sam.instance_segmentation`.
- implements training functionality that can be used for finetuning on your own data in `micro_sam.training`.
- provides functionality for quantitative and qualitative evaluation of Segment Anything models in `micro_sam.evaluation`.

Expand Down
1 change: 1 addition & 0 deletions finetuning/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ checkpoints/
logs/
sam_embeddings/
results/
*.sh
4 changes: 2 additions & 2 deletions finetuning/livecell_finetuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def get_dataloaders(patch_shape, data_path, cell_type=None):
"""
label_transform = torch_em.transform.label.label_consecutive # to ensure consecutive IDs
train_loader = get_livecell_loader(path=data_path, patch_shape=patch_shape, split="train", batch_size=2,
num_workers=8, cell_types=cell_type, download=True,
num_workers=16, cell_types=cell_type, download=True,
label_transform=label_transform, shuffle=True)
val_loader = get_livecell_loader(path=data_path, patch_shape=patch_shape, split="val", batch_size=1,
num_workers=8, cell_types=cell_type, download=True,
num_workers=16, cell_types=cell_type, download=True,
label_transform=label_transform, shuffle=True)
return train_loader, val_loader

Expand Down
8 changes: 4 additions & 4 deletions micro_sam/evaluation/livecell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from segment_anything import SamPredictor
from tqdm import tqdm

from ..instance_segmentation import AutomaticMaskGenerator, EmbeddingMaskGenerator
from ..instance_segmentation import AutomaticMaskGenerator, _EmbeddingMaskGenerator
from . import automatic_mask_generation, inference, evaluation
from .experiments import default_experiment_settings, full_experiment_settings

Expand Down Expand Up @@ -169,7 +169,7 @@ def run_livecell_amg(

if use_mws:
amg_prefix = "amg_mws"
AMG = EmbeddingMaskGenerator
AMG = _EmbeddingMaskGenerator
else:
amg_prefix = "amg"
AMG = AutomaticMaskGenerator
Expand Down Expand Up @@ -231,8 +231,8 @@ def run_livecell_inference() -> None:
# - automatic mask generation (auto)
# if none of the two are active then the prompt setting arguments will be parsed
# and used to run inference for a single prompt setting
parser.add_argument("-f", "--full_experiment", action="store_true")
parser.add_argument("-d", "--default_experiment", action="store_true")
parser.add_argument("-f", "--full_experiment", action="store_true")
parser.add_argument("-a", "--auto_mask_generation", action="store_true")

# the prompt settings for an individual inference run
Expand All @@ -242,7 +242,7 @@ def run_livecell_inference() -> None:
parser.add_argument("-n", "--negative", type=int, default=0, help="No. of negative prompts")

# optional external prompt folder
parser.add_argument("--prompt_folder", help="")
parser.add_argument("--prompt_folder", help="Provide the path where all input point prompts will be stored")

args = parser.parse_args()
if sum([args.full_experiment, args.default_experiment, args.auto_mask_generation]) > 2:
Expand Down