예제 #1
0
파일: cam.py 프로젝트: sebastianden/alpaca
def load_data(dataset):
    if dataset == 'test':
        X, y = load_test()
        sz = 230
    elif dataset == 'uc1':
        X, y = split_df(pd.read_pickle('..\\data\\df_uc1.pkl'),
                        index_column='run_id',
                        feature_columns=['fldPosition', 'fldCurrent'],
                        target_name='target')
        # Length of timeseries for resampler and cnn
        sz = 38
    elif dataset == 'uc2':
        X, y = split_df(pd.read_pickle('..\\data\\df_uc2.pkl'),
                        index_column='run_id',
                        feature_columns=['position', 'force'],
                        target_name='label')
        # Length of timeseries for resampler and cnn
        sz = 200
    resampler = TimeSeriesResampler(sz=sz)
    X = resampler.fit_transform(X, y)
    y = np.array(y)
    return X, y
예제 #2
0
from alpaca import Alpaca
from utils import to_time_series_dataset, to_dataset, split_df, TimeSeriesResampler 
import time
import numpy as np
import pandas as pd
from sklearn.pipeline import Pipeline

max_sample = 20

for dataset in ['uc2']:
    if dataset == 'uc1':
        X, y = split_df(pd.read_pickle('..\\data\\df_uc1.pkl'),
                        index_column='run_id',
                        feature_columns=['fldPosition', 'fldCurrent'],
                        target_name='target')
        y = np.array(y)
        # Length of timeseries for resampler and cnn
        sz = 38
        # Number of channels for cnn
        num_channels = len(X[0][0])
        # Number of classes for cnn
        num_classes = np.unique(y).shape[0]
    if dataset == 'uc2':
        X, y = split_df(pd.read_pickle('..\\data\\df_uc2.pkl'),
                        index_column='run_id',
                        feature_columns=['position', 'force'],
                        target_name='label')
        y = np.array(y)
        # Length of timeseries for resampler and cnn
        sz = 200
        # Number of channels for cnn
예제 #3
0
import utils

df_pickled_path = "./data.pkl"
data = utils.load_df_pickled(df_pickled_path)

train_data, valid_data, test_data = utils.split_df(data,
                                                   train_set_ratio=0.8,
                                                   test_set_ratio=0.1,
                                                   valid_set_ratio=0.1)

if __name__ == "__main__":
    pass
예제 #4
0
    print(f'The list different size image: {heigh_width_unique}')

    # Train file
    annot_df = pd.DataFrame.from_records(train_json['annotations'])
    annot_df['weight'] = heigh_width_unique[0][1]
    annot_df['height'] = heigh_width_unique[0][0]
    annot_df['x'] = annot_df['bbox'].apply(lambda x: x[0])
    annot_df['y'] = annot_df['bbox'].apply(lambda x: x[1])
    annot_df['w'] = annot_df['bbox'].apply(lambda x: x[2])
    annot_df['h'] = annot_df['bbox'].apply(lambda x: x[3])
    display(annot_df.head())

    # List label
    categorie_df = pd.DataFrame.from_records(train_json['categories'])
    display((categorie_df))

    # List image in folder
    train_image_path = glob(f'{args.train_image}/*.*')
    test_image_path = glob(f'{args.test_image}/*.*')

    print(
        f'Number of train image: {len(train_image_path)}, test image: {len(test_image_path)}'
    )

    # Create fold
    annot_pivot = split_df(annot_df)
    display(annot_pivot.head())

    #Train process
    train_pr = Train_process()
    train_pr.fit(annot_df, annot_pivot)