def main():

    # get experiment arguments
    args, _, config_model = get_args()
    args.experiment = "test_models"
    config_model["experiment"] = "test_models"

    # [STEP 1] create synthetic HAR batch
    data_synthetic = torch.randn(
        (args.batch_size, args.window, args.input_dim)).cuda()

    # [STEP 2] create HAR models
    if torch.cuda.is_available():
        model = create(args.model, config_model).cuda()
        torch.backends.cudnn.benchmark = True
        get_info_params(model)
        get_info_layers(model)
        model.apply(init_weights_orthogonal)

    model.eval()
    with torch.no_grad():
        print(paint("[*] Performing a forward pass with a synthetic batch..."))
        z, logits = model(data_synthetic)
        print(f"\t input: {data_synthetic.shape} {data_synthetic.dtype}")
        print(f"\t z: {z.shape} {z.dtype}")
        print(f"\t logits: {logits.shape} {logits.dtype}")
Exemple #2
0
    def __init__(self, data_dir):

        self.args = get_args()
        self.datadir = data_dir

        self.imgtypelist = self.args.img_type.split('_')
        self.camlist = self.args.cam_list.split('_')
        self.camlist_name = {
            '0': 'front',
            '1': 'right',
            '2': 'left',
            '3': 'back',
            '4': 'bottom'
        }

        self.imgclient = ImageClient(self.camlist, self.imgtypelist)
        self.randquaternionsampler = RandQuaternionSampler(self.args)

        self.trajdir = ''
        self.imgdirs = []
        self.depthdirs = []
        self.segdirs = []

        self.posefilelist = []  # save incremental pose files
        self.posenplist = []  # save pose in numpy files
Exemple #3
0
def main():

    # get experiment arguments
    args, config_dataset, _ = get_args()

    # [STEP 0 and 1] load the .mat files (sample-level) and partition the datasets (segment-level)
    preprocess_pipeline(args)

    # [STEP 2] create HAR datasets
    dataset = SensorDataset(**config_dataset, prefix="train", verbose=True)
Exemple #4
0
def main():

    # get experiment arguments
    args, config_dataset, config_model = get_args()

    # [STEP 0 and 1] load the .mat files (sample-level) and partition the datasets (segment-level)
    preprocess_pipeline(args)

    if args.train_mode:

        # [STEP 2] create HAR datasets
        dataset = SensorDataset(**config_dataset, prefix="train")
        dataset_val = SensorDataset(**config_dataset, prefix="val")

        # [STEP 3] create HAR models
        if torch.cuda.is_available():
            model = create(args.model, config_model).cuda()
            torch.backends.cudnn.benchmark = True
            sys.stdout = Logger(
                os.path.join(model.path_logs,
                             f"log_main_{args.experiment}.txt"))

        # show args
        print("##" * 50)
        print(paint(f"Experiment: {model.experiment}", "blue"))
        print(
            paint(
                f"[-] Using {torch.cuda.device_count()} GPU: {torch.cuda.is_available()}"
            ))
        print(args)
        get_info_params(model)
        get_info_layers(model)
        print("##" * 50)

        # [STEP 4] train HAR models
        model_train(model, dataset, dataset_val, args)

    # [STEP 5] evaluate HAR models
    dataset_test = SensorDataset(**config_dataset, prefix="test")
    if not args.train_mode:
        config_model["experiment"] = "inference"
        model = create(args.model, config_model).cuda()
    model_eval(model, dataset_test, args)
Exemple #5
0
def main():

    # get experiment arguments
    args, _, _ = get_args()
    preprocess_pipeline(args)