def create_training_dataset(self, event):
        """
        """
        num_shuffles = self.shuffles.GetValue()
        userfeedback_option = self.userfeedback.GetStringSelection()
        if userfeedback_option == 'Yes':
            userfeedback = True
        else:
            userfeedback = False
        trainindex = self.trainingindex.GetValue()

        if self.model_comparison_choice.GetStringSelection() == 'No':
            deeplabcut.create_training_dataset(
                self.config,
                num_shuffles,
                Shuffles=[self.shuffle.GetValue()],
                userfeedback=userfeedback,
                net_type=self.net_choice.GetValue(),
                augmenter_type=self.aug_choice.GetValue())
        if self.model_comparison_choice.GetStringSelection() == 'Yes':
            deeplabcut.create_training_model_comparison(
                self.config,
                trainindex=trainindex,
                num_shuffles=num_shuffles,
                userfeedback=userfeedback,
                net_types=self.net_type,
                augmenter_types=self.aug_type)
Example #2
0
 def create_training_dataset(self, event):
     """
     """
     num_shuffles = self.shuffles.GetValue()
     if self.model_comparison_choice.GetStringSelection() == 'No':
         deeplabcut.create_training_dataset(
             self.config,
             num_shuffles,
             net_type=self.net_choice.GetValue(),
             augmenter_type=self.aug_choice.GetValue())
     if self.model_comparison_choice.GetStringSelection() == 'Yes':
         deeplabcut.create_training_model_comparison(
             self.config,
             num_shuffles,
             net_types=self.net_type,
             augmenter_types=self.aug_type)
    def create_training_dataset(self, event):
        """
        """
        num_shuffles = self.shuffle.GetValue()
        config_file = auxiliaryfunctions.read_config(self.config)
        trainindex = self.trainingindex.GetValue()

        if self.userfeedback.GetStringSelection() == "Yes":
            userfeedback = True
        else:
            userfeedback = False

        if config_file.get("multianimalproject", False):
            if self.cropandlabel.GetStringSelection() == "Yes":
                n_crops, height, width = [
                    int(text.GetValue()) for _, text in self.crop_widgets
                ]
                deeplabcut.cropimagesandlabels(
                    self.config, n_crops, (height, width), userfeedback
                )
            else:
                random = False
            deeplabcut.create_multianimaltraining_dataset(
                self.config,
                num_shuffles,
                Shuffles=[self.shuffle.GetValue()],
                net_type=self.net_choice.GetValue(),
            )
        else:
            if self.model_comparison_choice.GetStringSelection() == "No":
                deeplabcut.create_training_dataset(
                    self.config,
                    num_shuffles,
                    Shuffles=[self.shuffle.GetValue()],
                    userfeedback=userfeedback,
                    net_type=self.net_choice.GetValue(),
                    augmenter_type=self.aug_choice.GetValue(),
                )
            if self.model_comparison_choice.GetStringSelection() == "Yes":
                deeplabcut.create_training_model_comparison(
                    self.config,
                    trainindex=trainindex,
                    num_shuffles=num_shuffles,
                    userfeedback=userfeedback,
                    net_types=self.net_type,
                    augmenter_types=self.aug_type,
                )
    def create_training_dataset(self, event):
        """
        """
        num_shuffles = self.shuffle.GetValue()
        config_file = auxiliaryfunctions.read_config(self.config)
        trainindex = self.trainingindex.GetValue()

        if self.userfeedback.GetStringSelection() == "Yes":
            userfeedback = True
        else:
            userfeedback = False

        if config_file.get("multianimalproject", False):
            deeplabcut.create_multianimaltraining_dataset(
                self.config,
                num_shuffles,
                Shuffles=[self.shuffle.GetValue()],
                net_type=self.net_choice.GetValue(),
            )
        else:
            if self.model_comparison_choice.GetStringSelection() == "No":
                deeplabcut.create_training_dataset(
                    self.config,
                    num_shuffles,
                    Shuffles=[self.shuffle.GetValue()],
                    userfeedback=userfeedback,
                    net_type=self.net_choice.GetValue(),
                    augmenter_type=self.aug_choice.GetValue(),
                )
            if self.model_comparison_choice.GetStringSelection() == "Yes":
                deeplabcut.create_training_model_comparison(
                    self.config,
                    trainindex=trainindex,
                    num_shuffles=num_shuffles,
                    userfeedback=userfeedback,
                    net_types=self.net_type,
                    augmenter_types=self.aug_type,
                )
Example #5
0
import deeplabcut
import numpy as np

# Loading example data set
path_config_file = os.path.join(os.getcwd(),
                                "openfield-Pranav-2018-10-30/config.yaml")
cfg = deeplabcut.auxiliaryfunctions.read_config(path_config_file)
maxiters = 10000

deeplabcut.load_demo_data(path_config_file)

## Create one split and make Shuffle 2 and 3 have the same split.
###Note that the new function in DLC 2.1 simplifies network/augmentation comparisons greatly:
deeplabcut.create_training_model_comparison(
    path_config_file,
    num_shuffles=1,
    net_types=["resnet_50", "efficientnet-b3"],
    augmenter_types=["imgaug", "scalecrop", "tensorpack"],
)

## here is an "old way" to do this
"""
trainIndices, testIndices=deeplabcut.mergeandsplit(path_config_file,trainindex=0,uniform=True)
deeplabcut.create_training_dataset(path_config_file,Shuffles=[2],trainIndices=trainIndices,testIndices=testIndices)
deeplabcut.create_training_dataset(path_config_file,Shuffles=[3],trainIndices=trainIndices,testIndices=testIndices)
for shuffle in [2,3]:
	if shuffle==3:
		posefile=os.path.join(cfg['project_path'],'dlc-models/iteration-'+str(cfg['iteration'])+'/'+ cfg['Task'] + cfg['date'] + '-trainset' + str(int(cfg['TrainingFraction'][0] * 100)) + 'shuffle' + str(shuffle),'train/pose_cfg.yaml')

		DLC_config=deeplabcut.auxiliaryfunctions.read_plainconfig(posefile)
		DLC_config['dataset_type']='tensorpack'
		deeplabcut.auxiliaryfunctions.write_plainconfig(posefile,DLC_config)
import deeplabcut
import numpy as np

# Loading example data set
path_config_file = os.path.join(os.getcwd(),
                                "openfield-Pranav-2018-10-30/config.yaml")
cfg = deeplabcut.auxiliaryfunctions.read_config(path_config_file)
maxiters = 10000

deeplabcut.load_demo_data(path_config_file)

## Create one split and make Shuffle 2 and 3 have the same split.
###Note that the new function in DLC 2.1 simplifies network/augmentation comparisons greatly:
deeplabcut.create_training_model_comparison(
    path_config_file,
    num_shuffles=1,
    net_types=["mobilenet_v2_0.35", "resnet_50", "efficientnet-b3"],
    augmenter_types=["imgaug"],
)

freezeencoder = False  # True
for shuffle in 1 + np.arange(3):

    posefile, _, _ = deeplabcut.return_train_network_path(path_config_file,
                                                          shuffle=shuffle)

    # for EfficientNet
    edits = {
        "decay_steps": maxiters,
        "lr_init": 0.0005 * 12,
        "freezeencoder": freezeencoder,
    }
Example #7
0
import os
os.environ["DLClight"]="True"

import deeplabcut as dlc

config_path = "/usr/users/onur.serce/dlc_real-alja_onur-2020-04-06/config.yaml"

print("'config_path' is:", config_path)
print("'dlc.__version__' is:'", dlc.__version__)
print("\n")

dlc.create_training_model_comparison(config_path, num_shuffles=10, net_types=['resnet_152'], augmenter_types=['imgaug'], userfeedback=False, windows2linux=True)

print('\n', 'create_training_model_comparison completed!')
trainIndexes, testIndexes=deeplabcut.mergeandsplit(path_config_file,trainindex=0,uniform=True)
deeplabcut.create_training_dataset(path_config_file,Shuffles=[2],trainIndexes=trainIndexes,testIndexes=testIndexes)
deeplabcut.create_training_dataset(path_config_file,Shuffles=[3],trainIndexes=trainIndexes,testIndexes=testIndexes)
for shuffle in [2,3]:
	if shuffle==3:
		posefile=os.path.join(cfg['project_path'],'dlc-models/iteration-'+str(cfg['iteration'])+'/'+ cfg['Task'] + cfg['date'] + '-trainset' + str(int(cfg['TrainingFraction'][0] * 100)) + 'shuffle' + str(shuffle),'train/pose_cfg.yaml')

		DLC_config=deeplabcut.auxiliaryfunctions.read_plainconfig(posefile)
		DLC_config['dataset_type']='tensorpack'
		deeplabcut.auxiliaryfunctions.write_plainconfig(posefile,DLC_config)
'''

###Note that the new function in DLC 2.1 does that much easier...
deeplabcut.create_training_model_comparison(
    path_config_file,
    num_shuffles=1,
    net_types=['resnet_50'],
    augmenter_types=['imgaug', 'default', 'tensorpack'])

for shuffle in [2, 3]:
    print("TRAIN NETWORK", shuffle)
    deeplabcut.train_network(path_config_file,
                             shuffle=shuffle,
                             saveiters=10000,
                             displayiters=200,
                             maxiters=5,
                             max_snapshots_to_keep=11)

    print("EVALUATE")
    deeplabcut.evaluate_network(path_config_file,
                                Shuffles=[shuffle],
Example #9
0
trainIndices, testIndices=deeplabcut.mergeandsplit(path_config_file,trainindex=0,uniform=True)
deeplabcut.create_training_dataset(path_config_file,Shuffles=[2],trainIndices=trainIndices,testIndices=testIndices)
deeplabcut.create_training_dataset(path_config_file,Shuffles=[3],trainIndices=trainIndices,testIndices=testIndices)
for shuffle in [2,3]:
	if shuffle==3:
		posefile=os.path.join(cfg['project_path'],'dlc-models/iteration-'+str(cfg['iteration'])+'/'+ cfg['Task'] + cfg['date'] + '-trainset' + str(int(cfg['TrainingFraction'][0] * 100)) + 'shuffle' + str(shuffle),'train/pose_cfg.yaml')

		DLC_config=deeplabcut.auxiliaryfunctions.read_plainconfig(posefile)
		DLC_config['dataset_type']='tensorpack'
		deeplabcut.auxiliaryfunctions.write_plainconfig(posefile,DLC_config)
"""

###Note that the new function in DLC 2.1 simplifies network/augmentation comparisons greatly:
deeplabcut.create_training_model_comparison(
    path_config_file,
    num_shuffles=1,
    net_types=["resnet_50"],
    augmenter_types=["imgaug", "default", "tensorpack"],
)
for shuffle in [1, 2, 3]:
    if shuffle < 3:
        posefile, _, _ = deeplabcut.return_train_network_path(path_config_file,
                                                              shuffle=shuffle)
        if shuffle == 2:  # Tensorpack:
            edits = {"rotate_max_deg_abs": 180, "noise_sigma": 0.01}
        elif shuffle == 1:  # imgaug
            edits = {"rotation": 180, "motion_blur": True}

        DLC_config = deeplabcut.auxiliaryfunctions.edit_config(posefile, edits)

    print("TRAIN NETWORK", shuffle)
    deeplabcut.train_network(