-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2defb9
commit d84a150
Showing
8 changed files
with
77 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
from trackastra.model.pretrained import download_pretrained | ||
import os | ||
|
||
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" | ||
|
||
if __name__ == "__main__": | ||
folder=download_pretrained("general_2d") | ||
import pytest | ||
import torch | ||
from trackastra.data import example_data_hela | ||
from trackastra.model import Trackastra | ||
|
||
|
||
@pytest.mark.parametrize("name", ["ctc", "general_2d"]) | ||
@pytest.mark.parametrize("device", ["cpu", "mps", "cuda"]) | ||
def test_pretrained(name, device): | ||
"""Each pretrained model should run on all (available) device.""" | ||
if device == "cuda": | ||
if torch.cuda.is_available(): | ||
run_predictions(name, "cuda") | ||
else: | ||
pytest.skip("cuda not available") | ||
elif device == "mps": | ||
if torch.backends.mps.is_available(): | ||
run_predictions(name, "mps") | ||
else: | ||
pytest.skip("mps not available") | ||
elif device == "cpu": | ||
# pytest.skip("cpu not needed") | ||
run_predictions(name, "cpu") | ||
else: | ||
raise ValueError() | ||
|
||
assert True | ||
|
||
|
||
def run_predictions(name, device): | ||
model = Trackastra.from_pretrained( | ||
name=name, | ||
device=device, | ||
) | ||
imgs, masks = example_data_hela() | ||
|
||
_ = model._predict(imgs, masks) | ||
assert True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import tifffile | ||
from pathlib import Path | ||
|
||
import tifffile | ||
|
||
root = Path(__file__).parent/'resources' | ||
root = Path(__file__).parent / "resources" | ||
|
||
def test_data_bacteria(): | ||
""" Bacteria images and masks from | ||
|
||
def example_data_bacteria(): | ||
"""Bacteria images and masks from. | ||
Van Vliet et al. Local interactions lead to spatially correlated gene expression levels in bacterial group (2018) | ||
subset of timelapse trpL/150310-11 | ||
""" | ||
img = tifffile.imread(root/'trpL_150310-11_img.tif') | ||
mask = tifffile.imread(root/'trpL_150310-11_mask.tif') | ||
return img, mask | ||
""" | ||
img = tifffile.imread(root / "trpL_150310-11_img.tif") | ||
mask = tifffile.imread(root / "trpL_150310-11_mask.tif") | ||
return img, mask | ||
|
||
|
||
def test_data_hela(): | ||
""" Hela data from the cell tracking challenge | ||
def example_data_hela(): | ||
"""Hela data from the cell tracking challenge. | ||
Neumann et al. Phenotypic profiling of the human genome by time-lapse microscopy reveals cell division genes (2010) | ||
subset of Fluo-N2DL-HeLa/train/02 | ||
""" | ||
img = tifffile.imread(root/'Fluo_Hela_02_img.tif') | ||
mask = tifffile.imread(root/'Fluo_Hela_02_ERR_SEG.tif') | ||
return img, mask | ||
img = tifffile.imread(root / "Fluo_Hela_02_img.tif") | ||
mask = tifffile.imread(root / "Fluo_Hela_02_ERR_SEG.tif") | ||
return img, mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# ruff: noqa: F401 | ||
|
||
from .model import TrackingTransformer | ||
from .model_api import Trackastra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters