from utils.configs.AlexNet_config import cfg as network_cfg # for Pascal VOC 2007 data set use: from utils.configs.Pascal_config import cfg as dataset_cfg # for the Grocery data set use: from utils.configs.Grocery_config import cfg as dataset_cfg from utils.configs.TNC_config import cfg as dataset_cfg return merge_configs([detector_cfg, network_cfg, dataset_cfg]) # trains and evaluates a Fast R-CNN model. if __name__ == '__main__': cfg = get_configuration() prepare(cfg, False) cntk.device.try_set_default_device(cntk.device.gpu(cfg.GPU_ID)) # train and test trained_model = train_faster_rcnn(cfg) eval_results = compute_test_set_aps(trained_model, cfg) # write AP results to output for class_name in eval_results: print('AP for {:>15} = {:.4f}'.format(class_name, eval_results[class_name])) print('Mean AP = {:.4f}'.format(np.nanmean(list(eval_results.values())))) # Plot results on test set images if cfg.VISUALIZE_RESULTS: num_eval = min(cfg["DATA"].NUM_TEST_IMAGES, 100) results_folder = os.path.join(cfg.OUTPUT_PATH, cfg["DATA"].DATASET) evaluator = FasterRCNN_Evaluator(trained_model, cfg) plot_test_set_results(evaluator, num_eval, results_folder, cfg) if cfg.STORE_EVAL_MODEL_WITH_NATIVE_UDF: store_eval_model_with_native_udf(trained_model, cfg)
from FasterRCNN_config import cfg as detector_cfg from utils.configs.VGG16_config import cfg as network_cfg from utils.configs.Building100_config import cfg as dataset_cfg return merge_configs([detector_cfg, network_cfg, dataset_cfg]) if __name__ == '__main__': cfg = get_configuration() prepare(cfg, False) #cntk.device.try_set_default_device(cntk.device.gpu(cfg.GPU_ID)) cntk.device.try_set_default_device(cntk.device.cpu()) model_path = cfg['MODEL_PATH'] print(model_path) if os.path.exists(model_path) and cfg["CNTK"].MAKE_MODE: print("Loading existing model from %s" % model_path) eval_model = load_model(model_path) else: print("No trained model found.") exit() # Plot results on test set images results_folder = os.path.join(cfg.OUTPUT_PATH, cfg["DATA"].DATASET) evaluator = FasterRCNN_Evaluator(eval_model, cfg) a = 'image.jpg' plot_test_file_results(evaluator, 'D:\\src\\CNTK_Faster_RCNN\\test_img\\' + a, 'D:\\src\\CNTK_Faster_RCNN\\test_img\\', cfg)