from learning.evaluators import RecallEvaluator as Evaluator from learning.utils import get_boxes, cal_recall from utils.visualization import draw_pred_boxes import cv2 import glob """ 1. Load dataset """ root_dir = os.path.join('data/face') test_dir = os.path.join(root_dir, 'test') IM_SIZE = (512, 512) NUM_CLASSES = 1 # Load test set X_test, y_test = dataset.read_data(test_dir, IM_SIZE) test_set = dataset.DataSet(X_test, y_test) """ 2. Set test hyperparameters """ class_map = dataset.load_json(os.path.join(test_dir, 'classes.json')) nms_flag = True hp_d = dict() hp_d['batch_size'] = 16 hp_d['nms_flag'] = nms_flag """ 3. Build graph, load weights, initialize a session and start test """ # Initialize graph = tf.get_default_graph() config = tf.ConfigProto() config.gpu_options.allow_growth = True model = ConvNet([IM_SIZE[0], IM_SIZE[1], 3], NUM_CLASSES) evaluator = Evaluator() saver = tf.train.Saver() sess = tf.Session(graph=graph, config=config)
import os import numpy as np import tensorflow as tf from datasets import data as dataset from models.nn import YOLO as ConvNet from learning.optimizers import MomentumOptimizer as Optimizer # from learning.optimizers import AdamOptimizer as Optimizer from learning.evaluators import RecallEvaluator as Evaluator """ 1. Load and split datasets """ root_dir = os.path.join('.\\data\\face\\') # FIXME trainval_dir = os.path.join(root_dir, 'train') # Load anchors anchors = dataset.load_json(os.path.join(trainval_dir, 'anchors.json')) # Set image size and number of class IM_SIZE = (416, 416) NUM_CLASSES = 1 # Load trainval set and split into train/val sets X_trainval, y_trainval = dataset.read_data(trainval_dir, IM_SIZE) trainval_size = X_trainval.shape[0] val_size = int(trainval_size * 0.1) # FIXME val_set = dataset.DataSet(X_trainval[:val_size], y_trainval[:val_size]) train_set = dataset.DataSet(X_trainval[val_size:], y_trainval[val_size:]) """ 2. Set training hyperparameters""" hp_d = dict() # FIXME: Training hyperparameters hp_d['batch_size'] = 2 hp_d['num_epochs'] = 50
import os import numpy as np import tensorflow as tf from datasets import data as dataset from models.nn import YOLO as ConvNet from learning.optimizers import MomentumOptimizer as Optimizer # from learning.optimizers import AdamOptimizer as Optimizer from learning.evaluators import RecallEvaluator as Evaluator """ 1. Load and split datasets """ root_dir = os.path.join('/home/intern/data/coco') # FIXME trainval_dir = os.path.join(root_dir, 'images') # Load anchors #anchors = dataset.load_json(os.path.join(trainval_dir, 'anchors.json')) anchors = dataset.load_json( os.path.join('/home/intern/data/face/train', 'anchors.json')) # Set image size and number of class IM_SIZE = (416, 416) NUM_CLASSES = 1 # Load trainval set and split into train/val sets X_trainval, y_trainval = dataset.read_data(trainval_dir, IM_SIZE) trainval_size = X_trainval.shape[0] val_size = int(trainval_size * 0.1) # FIXME val_set = dataset.DataSet(X_trainval[:val_size], y_trainval[:val_size]) train_set = dataset.DataSet(X_trainval[val_size:], y_trainval[val_size:]) """ 2. Set training hyperparameters""" hp_d = dict() # FIXME: Training hyperparameters