diff --git a/deeplabcut/create_project/modelzoo.py b/deeplabcut/create_project/modelzoo.py index 277b1db25f..d0617d93c9 100644 --- a/deeplabcut/create_project/modelzoo.py +++ b/deeplabcut/create_project/modelzoo.py @@ -219,7 +219,7 @@ def create_pretrained_project( os.path.join( config["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction=config["TrainingFraction"][0], shuffle=1, cfg=config, @@ -232,7 +232,7 @@ def create_pretrained_project( os.path.join( config["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction=config["TrainingFraction"][0], shuffle=1, cfg=config, @@ -246,7 +246,7 @@ def create_pretrained_project( train_dir.mkdir(parents=True, exist_ok=True) test_dir.mkdir(parents=True, exist_ok=True) - modelfoldername = auxiliaryfunctions.GetModelFolder( + modelfoldername = auxiliaryfunctions.get_model_folder( trainFraction=config["TrainingFraction"][0], shuffle=1, cfg=config ) path_train_config = str( diff --git a/deeplabcut/generate_training_dataset/multiple_individuals_trainingsetmanipulation.py b/deeplabcut/generate_training_dataset/multiple_individuals_trainingsetmanipulation.py index eb50f0349a..55618586c8 100755 --- a/deeplabcut/generate_training_dataset/multiple_individuals_trainingsetmanipulation.py +++ b/deeplabcut/generate_training_dataset/multiple_individuals_trainingsetmanipulation.py @@ -357,7 +357,7 @@ def create_multianimaltraining_dataset( # Test files as well as pose_yaml files (containing training and testing information) ################################################################################# - modelfoldername = auxiliaryfunctions.GetModelFolder( + modelfoldername = auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg ) auxiliaryfunctions.attempttomakefolder( diff --git a/deeplabcut/generate_training_dataset/trainingsetmanipulation.py b/deeplabcut/generate_training_dataset/trainingsetmanipulation.py index bdcd48b20f..f8990b1c70 100755 --- a/deeplabcut/generate_training_dataset/trainingsetmanipulation.py +++ b/deeplabcut/generate_training_dataset/trainingsetmanipulation.py @@ -956,7 +956,7 @@ def create_training_dataset( # Creating file structure for training & # Test files as well as pose_yaml files (containing training and testing information) ################################################################################# - modelfoldername = auxiliaryfunctions.GetModelFolder( + modelfoldername = auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg ) auxiliaryfunctions.attempttomakefolder( diff --git a/deeplabcut/gui/analyze_videos.py b/deeplabcut/gui/analyze_videos.py index be680d9282..3a028a4586 100644 --- a/deeplabcut/gui/analyze_videos.py +++ b/deeplabcut/gui/analyze_videos.py @@ -391,7 +391,7 @@ def edit_inf_config(self, event): #trainFraction = cfg["TrainingFraction"][trainingsetindex] self.inf_cfg_path = os.path.join( cfg["project_path"], - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, self.shuffle.GetValue(), cfg ), "test", diff --git a/deeplabcut/gui/evaluate_network.py b/deeplabcut/gui/evaluate_network.py index 30a495be3f..031f4ed433 100644 --- a/deeplabcut/gui/evaluate_network.py +++ b/deeplabcut/gui/evaluate_network.py @@ -233,7 +233,7 @@ def edit_inf_config(self, event): trainFraction = cfg["TrainingFraction"] self.inf_cfg_path = os.path.join( cfg["project_path"], - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction[-1], self.shuffles.GetValue(), cfg ), "test", diff --git a/deeplabcut/gui/refine_tracklets.py b/deeplabcut/gui/refine_tracklets.py index 054d49a282..2efdbc3900 100644 --- a/deeplabcut/gui/refine_tracklets.py +++ b/deeplabcut/gui/refine_tracklets.py @@ -227,7 +227,7 @@ def edit_inf_config(self, event): trainFraction = self.cfg["TrainingFraction"] self.inf_cfg_path = os.path.join( self.cfg["project_path"], - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction[-1], self.shuffle.GetValue(), self.cfg ), "test", diff --git a/deeplabcut/gui/train_network.py b/deeplabcut/gui/train_network.py index b2214560b6..ca1e69a40b 100644 --- a/deeplabcut/gui/train_network.py +++ b/deeplabcut/gui/train_network.py @@ -247,10 +247,10 @@ def edit_pose_config(self, event): cfg = auxiliaryfunctions.read_config(self.config) trainFraction = cfg["TrainingFraction"] #print(trainFraction[-1]) - # print(os.path.join(cfg['project_path'],auxiliaryfunctions.GetModelFolder(trainFraction, self.shuffles.GetValue(),cfg),'train','pose_cfg.yaml')) + # print(os.path.join(cfg['project_path'],auxiliaryfunctions.get_model_folder(trainFraction, self.shuffles.GetValue(),cfg),'train','pose_cfg.yaml')) self.pose_cfg_path = os.path.join( cfg["project_path"], - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction[-1], self.shuffles.GetValue(), cfg ), "train", diff --git a/deeplabcut/pose_estimation_tensorflow/core/evaluate.py b/deeplabcut/pose_estimation_tensorflow/core/evaluate.py index 325df04728..2851f7e389 100644 --- a/deeplabcut/pose_estimation_tensorflow/core/evaluate.py +++ b/deeplabcut/pose_estimation_tensorflow/core/evaluate.py @@ -85,7 +85,7 @@ def calculatepafdistancebounds( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -288,7 +288,7 @@ def return_evaluate_network_data( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -334,7 +334,7 @@ def return_evaluate_network_data( evaluationfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetEvaluationFolder( + auxiliaryfunctions.get_evaluation_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -649,7 +649,7 @@ def evaluate_network( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -681,7 +681,7 @@ def evaluate_network( evaluationfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetEvaluationFolder( + auxiliaryfunctions.get_evaluation_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), diff --git a/deeplabcut/pose_estimation_tensorflow/core/evaluate_multianimal.py b/deeplabcut/pose_estimation_tensorflow/core/evaluate_multianimal.py index 9c1edf127e..d327690f48 100644 --- a/deeplabcut/pose_estimation_tensorflow/core/evaluate_multianimal.py +++ b/deeplabcut/pose_estimation_tensorflow/core/evaluate_multianimal.py @@ -175,7 +175,7 @@ def evaluate_multianimal_full( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -218,7 +218,7 @@ def evaluate_multianimal_full( evaluationfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetEvaluationFolder( + auxiliaryfunctions.get_evaluation_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), diff --git a/deeplabcut/pose_estimation_tensorflow/export.py b/deeplabcut/pose_estimation_tensorflow/export.py index de6f096acf..6ba3ea8b39 100644 --- a/deeplabcut/pose_estimation_tensorflow/export.py +++ b/deeplabcut/pose_estimation_tensorflow/export.py @@ -114,7 +114,7 @@ def load_model(cfg, shuffle=1, trainingsetindex=0, TFGPUinference=True, modelpre model_folder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( train_fraction, shuffle, cfg, modelprefix=modelprefix ) ), diff --git a/deeplabcut/pose_estimation_tensorflow/predict_videos.py b/deeplabcut/pose_estimation_tensorflow/predict_videos.py index 1e1da14340..74af8f9ccc 100644 --- a/deeplabcut/pose_estimation_tensorflow/predict_videos.py +++ b/deeplabcut/pose_estimation_tensorflow/predict_videos.py @@ -99,7 +99,7 @@ def create_tracking_dataset( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -427,7 +427,7 @@ def analyze_videos( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -1234,7 +1234,7 @@ def analyze_time_lapse_frames( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -1586,7 +1586,7 @@ def convert_detections2tracklets( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), diff --git a/deeplabcut/pose_estimation_tensorflow/training.py b/deeplabcut/pose_estimation_tensorflow/training.py index be3a3b6202..7998c6fdcb 100644 --- a/deeplabcut/pose_estimation_tensorflow/training.py +++ b/deeplabcut/pose_estimation_tensorflow/training.py @@ -30,7 +30,7 @@ def return_train_network_path(config, shuffle=1, trainingsetindex=0, modelprefix from deeplabcut.utils import auxiliaryfunctions cfg = auxiliaryfunctions.read_config(config) - modelfoldername = auxiliaryfunctions.GetModelFolder( + modelfoldername = auxiliaryfunctions.get_model_folder( cfg["TrainingFraction"][trainingsetindex], shuffle, cfg, modelprefix=modelprefix ) trainposeconfigfile = Path( @@ -130,7 +130,7 @@ def train_network( # Read file path for pose_config file. >> pass it on cfg = auxiliaryfunctions.read_config(config) - modelfoldername = auxiliaryfunctions.GetModelFolder( + modelfoldername = auxiliaryfunctions.get_model_folder( cfg["TrainingFraction"][trainingsetindex], shuffle, cfg, modelprefix=modelprefix ) poseconfigfile = Path( diff --git a/deeplabcut/pose_estimation_tensorflow/visualizemaps.py b/deeplabcut/pose_estimation_tensorflow/visualizemaps.py index b51e7c69e7..fb3f2da9e8 100644 --- a/deeplabcut/pose_estimation_tensorflow/visualizemaps.py +++ b/deeplabcut/pose_estimation_tensorflow/visualizemaps.py @@ -120,7 +120,7 @@ def extract_maps( modelfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetModelFolder( + auxiliaryfunctions.get_model_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -150,7 +150,7 @@ def extract_maps( evaluationfolder = os.path.join( cfg["project_path"], str( - auxiliaryfunctions.GetEvaluationFolder( + auxiliaryfunctions.get_evaluation_folder( trainFraction, shuffle, cfg, modelprefix=modelprefix ) ), @@ -419,7 +419,7 @@ def extract_save_all_maps( from deeplabcut.utils.auxiliaryfunctions import ( read_config, attempttomakefolder, - GetEvaluationFolder, + get_evaluation_folder, IntersectionofBodyPartsandOnesGivenbyUser, ) from tqdm import tqdm @@ -438,7 +438,7 @@ def extract_save_all_maps( if not dest_folder: dest_folder = os.path.join( cfg["project_path"], - str(GetEvaluationFolder(frac, shuffle, cfg, modelprefix=modelprefix)), + str(get_evaluation_folder(frac, shuffle, cfg, modelprefix=modelprefix)), "maps", ) attempttomakefolder(dest_folder) diff --git a/deeplabcut/utils/auxiliaryfunctions.py b/deeplabcut/utils/auxiliaryfunctions.py index 450d988749..fb874ce8cc 100644 --- a/deeplabcut/utils/auxiliaryfunctions.py +++ b/deeplabcut/utils/auxiliaryfunctions.py @@ -470,7 +470,7 @@ def GetDataandMetaDataFilenames(trainingsetfolder, trainFraction, shuffle, cfg): return datafn, metadatafn -def GetModelFolder(trainFraction, shuffle, cfg, modelprefix=""): +def get_model_folder(trainFraction, shuffle, cfg, modelprefix=""): Task = cfg["Task"] date = cfg["date"] iterate = "iteration-" + str(cfg["iteration"]) @@ -487,7 +487,7 @@ def GetModelFolder(trainFraction, shuffle, cfg, modelprefix=""): ) -def GetEvaluationFolder(trainFraction, shuffle, cfg, modelprefix=""): +def get_evaluation_folder(trainFraction, shuffle, cfg, modelprefix=""): Task = cfg["Task"] date = cfg["date"] iterate = "iteration-" + str(cfg["iteration"]) @@ -570,7 +570,7 @@ def GetScorerName( modelfolder = os.path.join( cfg["project_path"], - str(GetModelFolder(trainFraction, shuffle, cfg, modelprefix=modelprefix)), + str(get_model_folder(trainFraction, shuffle, cfg, modelprefix=modelprefix)), "train", ) Snapshots = np.array( @@ -584,7 +584,7 @@ def GetScorerName( dlc_cfg = read_plainconfig( os.path.join( cfg["project_path"], - str(GetModelFolder(trainFraction, shuffle, cfg, modelprefix=modelprefix)), + str(get_model_folder(trainFraction, shuffle, cfg, modelprefix=modelprefix)), "train", "pose_cfg.yaml", ) @@ -742,6 +742,7 @@ def find_analyzed_data(folder, videoname, scorer, filtered=False, track_method=" ) ): candidates.append(file) + if not len(candidates): msg = ( f'No {"un" if not filtered else ""}filtered data file found in {folder} ' diff --git a/deeplabcut/version.py b/deeplabcut/version.py index 6f837de355..dc3e52f597 100644 --- a/deeplabcut/version.py +++ b/deeplabcut/version.py @@ -8,5 +8,5 @@ Licensed under GNU Lesser General Public License v3.0 """ -__version__ = "2.2.1rc1" +__version__ = "2.2.1" VERSION = __version__ diff --git a/examples/test.sh b/examples/test.sh index 0f1ebf4396..f707f18fa2 100755 --- a/examples/test.sh +++ b/examples/test.sh @@ -6,7 +6,7 @@ rm -r OUT cd .. pip uninstall deeplabcut python3 setup.py sdist bdist_wheel -pip install dist/deeplabcut-2.2.1rc1-py3-none-any.whl +pip install dist/deeplabcut-2.2.1-py3-none-any.whl cd examples diff --git a/examples/testM1.sh b/examples/testM1.sh index e24769b54d..c6ab3fefb5 100755 --- a/examples/testM1.sh +++ b/examples/testM1.sh @@ -10,7 +10,7 @@ rm -r OUT cd .. pip uninstall deeplabcut pythonw setup.py sdist bdist_wheel -pip install dist/deeplabcut-2.2.1rc1-py3-none-any.whl +pip install dist/deeplabcut-2.2.1-py3-none-any.whl # download: https://drive.google.com/file/d/17pSwfoNuyf3YR8vCaVggHeI-pMQ3xL7l/view?usp=sharing # assuming it's in Downloads... diff --git a/examples/testscript_multianimal.py b/examples/testscript_multianimal.py index f243c77247..e864e33b0c 100644 --- a/examples/testscript_multianimal.py +++ b/examples/testscript_multianimal.py @@ -120,7 +120,7 @@ assert all(len(pickledata[i]["image"]) == 3 for i in range(num_images)) print("Editing pose config...") - model_folder = auxiliaryfunctions.GetModelFolder( + model_folder = auxiliaryfunctions.get_model_folder( TRAIN_SIZE, 1, cfg, cfg["project_path"] ) pose_config_path = os.path.join(model_folder, "train", "pose_cfg.yaml") diff --git a/examples/testscript_transreid.py b/examples/testscript_transreid.py index 9ba151c9c5..28cfdadcd7 100644 --- a/examples/testscript_transreid.py +++ b/examples/testscript_transreid.py @@ -122,7 +122,7 @@ assert all(len(pickledata[i]["joints"]) == 3 for i in range(num_images)) print("Editing pose config...") - model_folder = auxiliaryfunctions.GetModelFolder( + model_folder = auxiliaryfunctions.get_model_folder( TRAIN_SIZE, 1, cfg, cfg["project_path"] ) pose_config_path = os.path.join(model_folder, "train", "pose_cfg.yaml") diff --git a/reinstall.sh b/reinstall.sh index 8e734542c7..a8d875554a 100755 --- a/reinstall.sh +++ b/reinstall.sh @@ -1,3 +1,3 @@ pip uninstall deeplabcut python3 setup.py sdist bdist_wheel -pip install dist/deeplabcut-2.2.1rc1-py3-none-any.whl +pip install dist/deeplabcut-2.2.1-py3-none-any.whl diff --git a/setup.py b/setup.py index ce56791a4a..6d02c1cf99 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setuptools.setup( name="deeplabcut", - version="2.2.1rc1", + version="2.2.1", author="A. & M. Mathis Labs", author_email="alexander@deeplabcut.org", description="Markerless pose-estimation of user-defined features with deep learning", @@ -43,7 +43,6 @@ "tensorpack>=0.11", "tf_slim>=1.1.0", "tqdm", - "torch", "pyyaml", "Pillow>=7.1", ], diff --git a/tests/test_auxiliaryfunctions.py b/tests/test_auxiliaryfunctions.py index 9689770cd4..b24777e028 100644 --- a/tests/test_auxiliaryfunctions.py +++ b/tests/test_auxiliaryfunctions.py @@ -2,6 +2,40 @@ from deeplabcut.utils.auxfun_videos import SUPPORTED_VIDEOS +def test_find_analyzed_data(tmpdir_factory): + import os + import pytest + + fake_folder = tmpdir_factory.mktemp('videos') + SUPPORTED_VIDEOS=['avi'] + n_ext = len(SUPPORTED_VIDEOS) + + SCORER = 'DLC_dlcrnetms5_multi_mouseApr11shuffle1_5' + WRONG_SCORER = 'DLC_dlcrnetms5_multi_mouseApr11shuffle3_5' + + def _create_fake_file(filename): + path = str(fake_folder.join(filename)) + with open(path, "w") as f: + f.write("") + return path + + for ind, ext in enumerate(SUPPORTED_VIDEOS): + vname="video"+str(ind) + _ = _create_fake_file(vname+'.'+ext) + _ = _create_fake_file(vname+SCORER+".pickle") + _ = _create_fake_file(vname+SCORER+".h5") + + for ind, ext in enumerate(SUPPORTED_VIDEOS): + # test if existing models are found: + assert auxiliaryfunctions.find_analyzed_data(fake_folder, "video"+str(ind), SCORER) + + # Test if nonexisting models are not found + with pytest.raises(FileNotFoundError): + auxiliaryfunctions.find_analyzed_data(fake_folder, "video"+str(ind), WRONG_SCORER) + + with pytest.raises(FileNotFoundError): + auxiliaryfunctions.find_analyzed_data(fake_folder, "video"+str(ind), SCORER,filtered=True) + def test_get_list_of_videos(tmpdir_factory): fake_folder = tmpdir_factory.mktemp('videos') n_ext = len(SUPPORTED_VIDEOS) @@ -16,11 +50,11 @@ def _create_fake_file(filename): for ext in SUPPORTED_VIDEOS: path = _create_fake_file(f"fake.{ext}") fake_videos.append(path) - + # Add some other office files: path = _create_fake_file("fake.xls") path = _create_fake_file("fake.pptx") - + # Add a .pickle and .h5 files _ = _create_fake_file("fake.pickle") _ = _create_fake_file("fake.h5")