This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_dataset(X, y, time_steps=1, step=1): | |
Xs, ys = [], [] | |
for i in range(0, len(X) - time_steps, step): | |
v = X.iloc[i:(i + time_steps)].values | |
labels = y.iloc[i: i + time_steps] | |
Xs.append(v) | |
ys.append(stats.mode(labels)[0][0]) | |
return np.array(Xs), np.array(ys).reshape(-1, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scale_columns = ['x_axis', 'y_axis', 'z_axis'] | |
scaler = RobustScaler() | |
scaler = scaler.fit(df_train[scale_columns]) | |
df_train.loc[:, scale_columns] = scaler.transform( | |
df_train[scale_columns].to_numpy() | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_train = df[df['user_id'] <= 30] | |
df_test = df[df['user_id'] > 30] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
column_names = [ | |
'user_id', | |
'activity', | |
'timestamp', | |
'x_axis', | |
'y_axis', | |
'z_axis' | |
] | |
df = pd.read_csv( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.makedirs("annotated_results", exist_ok=True) | |
test_image_paths = test_df.file_name.unique() | |
for clothing_image in test_image_paths: | |
file_path = f'{IMAGES_PATH}/{clothing_image}' | |
im = cv2.imread(file_path) | |
outputs = predictor(im) | |
v = Visualizer( | |
im[:, :, ::-1], | |
metadata=statement_metadata, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
evaluator = COCOEvaluator("faces_val", cfg, False, output_dir="./output/") | |
val_loader = build_detection_test_loader(cfg, "faces_val") | |
inference_on_dataset(trainer.model, val_loader, evaluator) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final.pth") | |
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.85 | |
predictor = DefaultPredictor(cfg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True) | |
trainer = CocoTrainer(cfg) | |
trainer.resume_or_load(resume=False) | |
trainer.train() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 64 | |
cfg.MODEL.ROI_HEADS.NUM_CLASSES = len(classes) | |
cfg.TEST.EVAL_PERIOD = 500 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cfg.SOLVER.IMS_PER_BATCH = 4 | |
cfg.SOLVER.BASE_LR = 0.001 | |
cfg.SOLVER.WARMUP_ITERS = 1000 | |
cfg.SOLVER.MAX_ITER = 1500 | |
cfg.SOLVER.STEPS = (1000, 1500) | |
cfg.SOLVER.GAMMA = 0.05 |