LINCellularNeuroscience/VAME

Run project without copying videos?

SusanL82 opened this issue · 1 comments

Hi VAME team,

I am planning to run VAME on a pretty big group of videos and I was wondering if it is possible to do this without having to copy all of the videos to the VAME project folder (I am running into some space issues).
Is there some way to enter a path for the videos directly? I will have a look through the functions themselves soon, but if not copying is completely impossible, you can maybe save me the trouble.

Best,
Susan

@SusanL82 check my comments on issue #127

I think that could help you out! I have additionally edited the 'create_trainset' to allow you to enter your own list of video file path names to create a training data of specific videos. This should work without copying them into the vame video folder but I have not tested that:

def create_trainset(config, check_parameter=False, data_fraction=None):
    config_file = Path(config).resolve()
    cfg = read_config(config_file)
    legacy = cfg['legacy']
    fixed = cfg['egocentric_data']
    
    if not os.path.exists(os.path.join(cfg['project_path'],'data','train',"")):
        os.mkdir(os.path.join(cfg['project_path'],'data','train',""))

    files = []
    if cfg['all_data'] == 'No':
        for file in cfg['video_sets']:
            use_list = input("Do you have a list of videos you want to use for training? yes/no: ")
            if use_list == 'yes':
                files_input = input("Please enter the list of videos you want to use for training: ")
                files = [clean_input(f) for f in files_input.split(',')]
                break
            elif use_list == 'no':
                use_file = input("Do you want to train on " + file + "? yes/no: ")
                if use_file == 'yes':
                    files.append(file)
                if use_file == 'no':
                    continue
            else:
                print("Invalid input. Please enter 'yes' or 'no'.")
    else:
        for file in cfg['video_sets']:
            files.append(file)

    print("Creating training dataset...")
    if cfg['robust'] == True:
        print("Using robust setting to eliminate outliers! IQR factor: %d" %cfg['iqr_factor'])
        
    if fixed == False:
        if data_fraction == None:
            print("Creating trainset from the vame.egocentrical_alignment() output ")
            traindata_aligned(cfg, files, cfg['test_fraction'], cfg['num_features'], cfg['savgol_filter'], check_parameter)
        elif data_fraction != None:
            print("Creating trainset from the vame.egocentrical_alignment() output ")
            traindata_aligned_fractional(cfg, files, cfg['test_fraction'], cfg['num_features'], cfg['savgol_filter'], check_parameter, data_fraction)
    else:
        print("Creating trainset from the vame.csv_to_numpy() output ")
        traindata_fixed(cfg, files, cfg['test_fraction'], cfg['num_features'], cfg['savgol_filter'], check_parameter)
    
    if check_parameter == False:
        print("A training and test set has been created. Next step: vame.train_model()")
        

Just copy this function in place of the original 'def create_trainset' at the bottom of the file vame/model/create_training.py.

Let me know if you run into any issues or have questions!