Skip to content
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
2 changes: 2 additions & 0 deletions synapse_net/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def get_model_training_resolution(model_type: str) -> Dict[str, float]:
"active_zone": {"x": 1.38, "y": 1.38, "z": 1.38},
"compartments": {"x": 3.47, "y": 3.47, "z": 3.47},
"mitochondria": {"x": 2.07, "y": 2.07, "z": 2.07},
# TODO: this is just copied from the previous mito model, it may be necessary to update this.
"mitochondria2": {"x": 2.07, "y": 2.07, "z": 2.07},
"cristae": {"x": 1.44, "y": 1.44, "z": 1.44},
"ribbon": {"x": 1.188, "y": 1.188, "z": 1.188},
"vesicles_2d": {"x": 1.35, "y": 1.35},
Expand Down
21 changes: 21 additions & 0 deletions test/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from shutil import rmtree

import imageio.v3 as imageio
import requests
from synapse_net.file_utils import read_mrc
from synapse_net.sample_data import get_sample_data

Expand All @@ -23,6 +24,26 @@ def tearDown(self):
except OSError:
pass

# Test that all models can be accessed by pooch and have the necessary resolution information.
def test_models(self):
from synapse_net.inference.inference import _get_model_registry, get_model_training_resolution

def check_url(url):
try:
# Make a HEAD request to the URL, which fetches HTTP headers but no content.
response = requests.head(url, allow_redirects=True)
# Check if the HTTP status code is one that indicates availability (200 <= code < 400).
return response.status_code < 400
except requests.RequestException:
# Handle connection exceptions
return False

registry = _get_model_registry()
for name in registry.registry.keys():
url_exists = check_url(registry.get_url(name))
self.assertTrue(url_exists)
get_model_training_resolution(name)

def test_run_segmentation(self):
from synapse_net.inference import run_segmentation, get_model

Expand Down