diff --git a/4-Object_Detection/RPN/train.py b/4-Object_Detection/RPN/train.py index b1f72926..d7821915 100644 --- a/4-Object_Detection/RPN/train.py +++ b/4-Object_Detection/RPN/train.py @@ -119,12 +119,14 @@ def compute_loss(target_scores, target_bboxes, target_masks, pred_scores, pred_b STEPS = 4000 batch_size = 2 lambda_scale = 1. -synthetic_dataset_path="./synthetic_dataset" +project_directory = os.path.dirname(__file__) +synthetic_dataset_path=os.path.join(project_directory, "synthetic_dataset") +weights_path = os.path.join(project_directory, "RPN.h5") TrainSet = DataGenerator(synthetic_dataset_path, batch_size) model = RPNplus() optimizer = tf.keras.optimizers.Adam(lr=1e-4) -writer = tf.summary.create_file_writer("./log") +writer = tf.summary.create_file_writer(os.path.join(project_directory, "log")) global_steps = tf.Variable(0, trainable=False, dtype=tf.int64) for epoch in range(EPOCHS): @@ -145,7 +147,7 @@ def compute_loss(target_scores, target_bboxes, target_masks, pred_scores, pred_b tf.summary.scalar("score_loss", score_loss, step=global_steps) tf.summary.scalar("boxes_loss", boxes_loss, step=global_steps) writer.flush() - model.save_weights("RPN.h5") + model.save_weights(weights_path) diff --git a/4-Object_Detection/YOLOV3/core/config.py b/4-Object_Detection/YOLOV3/core/config.py index f23265ca..a3a49eb7 100644 --- a/4-Object_Detection/YOLOV3/core/config.py +++ b/4-Object_Detection/YOLOV3/core/config.py @@ -12,6 +12,7 @@ #================================================================ from easydict import EasyDict as edict +import os __C = edict() @@ -23,8 +24,10 @@ __C.YOLO = edict() # Set the class name -__C.YOLO.CLASSES = "./data/classes/coco.names" -__C.YOLO.ANCHORS = "./data/anchors/basline_anchors.txt" +project_directory = os.path.dirname(os.path.dirname(__file__)) + +__C.YOLO.CLASSES = os.path.join(project_directory, "data/classes/coco.names") +__C.YOLO.ANCHORS = os.path.join(project_directory, "data/anchors/basline_anchors.txt") __C.YOLO.STRIDES = [8, 16, 32] __C.YOLO.ANCHOR_PER_SCALE = 3 __C.YOLO.IOU_LOSS_THRESH = 0.5 @@ -32,7 +35,7 @@ # Train options __C.TRAIN = edict() -__C.TRAIN.ANNOT_PATH = "./data/dataset/yymnist_train.txt" +__C.TRAIN.ANNOT_PATH = os.path.join(project_directory, "data/dataset/yymnist_train.txt") __C.TRAIN.BATCH_SIZE = 4 # __C.TRAIN.INPUT_SIZE = [320, 352, 384, 416, 448, 480, 512, 544, 576, 608] __C.TRAIN.INPUT_SIZE = [416] @@ -47,11 +50,11 @@ # TEST options __C.TEST = edict() -__C.TEST.ANNOT_PATH = "./data/dataset/yymnist_test.txt" +__C.TEST.ANNOT_PATH = os.path.join(project_directory, "data/dataset/yymnist_test.txt") __C.TEST.BATCH_SIZE = 2 __C.TEST.INPUT_SIZE = 544 __C.TEST.DATA_AUG = False -__C.TEST.DECTECTED_IMAGE_PATH = "./data/detection/" +__C.TEST.DECTECTED_IMAGE_PATH = os.path.join(project_directory, "data/detection/") __C.TEST.SCORE_THRESHOLD = 0.3 __C.TEST.IOU_THRESHOLD = 0.45