diff --git a/pyproject.toml b/pyproject.toml index e03ecd6e24d88dc9d88d605d5f6b326486203130..59cc1eddb90b910e9013ad0bea169ce2f4762a98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "MaggotUBA-adapter" -version = "0.18" +version = "0.19" description = "Interface between MaggotUBA and the Nyx tagging UI" authors = ["François Laurent"] license = "MIT" @@ -14,7 +14,7 @@ maggotuba-core = {git = "https://gitlab.pasteur.fr/nyx/MaggotUBA-core", tag = "v torch = "^1.11.0" numpy = "^1.19.3" protobuf = "3.9.2" -taggingbackends = {git = "https://gitlab.pasteur.fr/nyx/TaggingBackends", rev = "v0.17"} +taggingbackends = {git = "https://gitlab.pasteur.fr/nyx/TaggingBackends", rev = "v0.18"} [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..de951125d8a027024f4cdc2a5b51f4dddab4f422 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,25 @@ +attrdict==2.0.1 +certifi==2023.11.17 +charset-normalizer==3.3.2 +h5py==3.1.0 +hdf5storage==0.1.19 +idna==3.6 +julia==0.5.7 +numpy==1.24.4 +nvidia-cublas-cu11==11.10.3.66 +nvidia-cuda-nvrtc-cu11==11.7.99 +nvidia-cuda-runtime-cu11==11.7.99 +nvidia-cudnn-cu11==8.5.0.96 +pandas==1.3.3 +Pillow==10.1.0 +protobuf==3.9.2 +python-dateutil==2.8.2 +pytz==2023.3.post1 +PyYAML==6.0.1 +requests==2.31.0 +six==1.16.0 +torch==1.13.1 +torchvision==0.14.1 +tqdm==4.66.1 +typing_extensions==4.9.0 +urllib3==2.1.0 diff --git a/src/maggotuba/models/modules.py b/src/maggotuba/models/modules.py index cb3cf322a90543341cf0bdfe1554b8fffc53a679..5ba29f7efc093e34d8346b96dcb9435d18834b96 100644 --- a/src/maggotuba/models/modules.py +++ b/src/maggotuba/models/modules.py @@ -184,7 +184,7 @@ class MaggotEncoder(MaggotModule): _reason = e config['load_state'] = False # for `was_pretrained` to properly work else: - logging.debug(f"loading neural network state: {path}") + logging.debug(f"neural network state loaded: {path}") else: _reason = '"load_state" is set to false' # if state file not found or config option "load_state" is False, @@ -336,8 +336,8 @@ class DeepLinear(nn.Module): return self.layers(x) def load(self, path): - logging.debug(f"loading neural network state: {path}") self.load_state_dict(torch.load(path)) + logging.debug(f"neural network state loaded: {path}") def save(self, path): logging.debug(f"saving neural network state to file: {path}") diff --git a/src/maggotuba/models/predict_model.py b/src/maggotuba/models/predict_model.py index c4cb3ac7c15e12174b7dd4713730999991afe7b2..cc0d50ba38f240f674b3140481e67209908b1778 100644 --- a/src/maggotuba/models/predict_model.py +++ b/src/maggotuba/models/predict_model.py @@ -3,6 +3,11 @@ from taggingbackends.features.skeleton import get_5point_spines from maggotuba.models.trainers import MaggotTrainer, MultiscaleMaggotTrainer, MaggotBagging, new_generator import numpy as np import logging +import os.path + + +tracking_data_file_extensions = ('.spine', '.outline', '.csv', '.mat', '.hdf5') + def predict_model(backend, **kwargs): """ @@ -27,13 +32,13 @@ def predict_model(backend, **kwargs): assert 0 < len(input_files) # initialize output labels - input_files_and_labels = backend.prepare_labels(input_files) + input_files_and_labels = backend.prepare_labels(input_files, single_input=True, + allowed_file_extensions=tracking_data_file_extensions) assert 0 < len(input_files_and_labels) # load the model model_files = backend.list_model_files() - config_files = [file - for file in model_files + config_files = [file for file in model_files if file.name.endswith('config.json')] if len(config_files) == 0: raise RuntimeError(f"no config files found for tagger: {backend.model_instance}") diff --git a/src/maggotuba/models/trainers.py b/src/maggotuba/models/trainers.py index 2d41bea9aa24d68ea4b455d0f3ad1c9e81a4fe2f..ea0e3220adb4ba8fc226c62e349f0c43a3337309 100644 --- a/src/maggotuba/models/trainers.py +++ b/src/maggotuba/models/trainers.py @@ -70,7 +70,7 @@ class MaggotTrainer: def prepare_dataset(self, dataset, training=False): if training: - self.model.clf.config['training_dataset'] = str(dataset.path) + self.model.clf.config['training_dataset'] = self.model.path_for_config(dataset.path) try: dataset.batch_size except AttributeError: