예제 #1
0
def parse_command_line():
    parser = argparse.ArgumentParser(description="""Tests a trained Caffe model to see how well
        it does, generating quality graphs and statistics""")
    parser.add_argument("--log_path", help="The path to where to place log files and graphs",
        type=str, default="logs")
    parser.add_argument("--log_num", help="""Number that will be appended to log files; this will
        be automatically padded and added with zeros, such as output00001.log""", type=int,
        default=1)
    parser.add_argument("--input_weight_file", help="""The trained and fine-tuned Caffe model that
        we will be testing; defaults to the last trained model from train.py""", type=str,
        default="logs/latest_bvlc_alexnet_finetuned.caffemodel")
    parser.add_argument("--note", help="Adds extra note onto generated quality graphs.", type=str,
        default="")
    parser.add_argument("--solver", help="The path to our Caffe solver prototxt file",
        type=str, default="src/caffe_model/bvlc_alexnet/solver.prototxt")
    parser.add_argument("--deploy", help="""Path to our Caffe deploy/inference time prototxt file""",
        type=str, default="src/caffe_model/bvlc_alexnet/deploy.prototxt")
    parser.add_argument("--threshold", help="""The percentage threshold over which we assume
        something is a cloud. Note that this value is from 0.0 to 100.0""", type=float, default=0.1)
    parser.add_argument("--validation_leveldb", help="""Path to where the validation leveldb file is""",
        type=str, default="data/leveldb/validation_leveldb")
    parser.add_argument("--width", help="Width of image during training", type=int, default=256)
    parser.add_argument("--height", help="Height of image during training", type=int, default=256)
    parser.add_argument("--inference_width", help="Width of image during training", type=int,
        default=227)
    parser.add_argument("--inference_height", help="Height of image during training", type=int,
        default=227)
    parser.add_argument("--training_mean_pickle", help="Path to pickled mean values", type=str,
        default="data/imagenet/imagenet_mean.npy")

    args = vars(parser.parse_args())

    print "Testing trained model..."

    caffe_home = utils.assert_caffe_setup()

    # Ensure the random number generator always starts from the same place for consistent tests.
    random.seed(0)

    log_path = os.path.abspath(args["log_path"])
    log_num = args["log_num"]
    (output_ending, output_log_prefix, output_log_file) = utils.get_log_path_details(log_path, log_num)
    output_graph_path = output_log_prefix

    (training_details, validation_details) = utils.parse_logs(log_path, output_log_file)

    plot_results(training_details, validation_details, args["note"], output_graph_path, args["solver"])
    validation_leveldb = os.path.abspath(args["validation_leveldb"])
    deploy = os.path.abspath(args["deploy"])
    input_weight_file = os.path.abspath(args["input_weight_file"])
    training_mean_pickle = os.path.abspath(args["training_mean_pickle"])
    predict.test_validation(args["threshold"], output_log_prefix, validation_leveldb,
        deploy, args["width"], args["height"], args["inference_width"],
        args["inference_height"], input_weight_file, training_mean_pickle)
예제 #2
0
def train(output_graphs, data=None, note=None):
    print("Training data, generating graphs: %r" % output_graphs)

    _run_trainer()

    _generate_parsed_logs()
    (training_details, validation_details) = _parse_logs()
    _move_trained_weight_file()

    if output_graphs:
        graph.plot_results(training_details, validation_details, note)
        predict.test_validation()
예제 #3
0
def train(output_graphs, data=None, note=None):
    print("Training data, generating graphs: %r" % output_graphs)

    _run_trainer()

    _generate_parsed_logs()
    (training_details, validation_details) = _parse_logs()
    _move_trained_weight_file()

    if output_graphs:
        graph.plot_results(training_details, validation_details, note)
        predict.test_validation()
예제 #4
0
파일: train.py 프로젝트: max-nova/cloudless
def train(output_graphs, data=None, weight_file=None, note=None):
    print("Training data, generating graphs: %r" % output_graphs)

    run_trainer()
    generate_parsed_logs()
    (training_details, validation_details) = parse_logs()
    # TODO(neuberg): This will need to be adapted against an already trained weight
    # file that we are fine-tuning.
    trained_weight_file = get_trained_weight_file()

    if output_graphs:
        graph.plot_results(training_details, validation_details, note)

        # If no weight file is provided by callers to this method, parse out the one we just
        # trained.
        if weight_file == None:
            weight_file = trained_weight_file
        predict.test_validation(data, weight_file)
예제 #5
0
파일: train.py 프로젝트: max-nova/cloudless
def train(output_graphs, data=None, weight_file=None, note=None):
    print("Training data, generating graphs: %r" % output_graphs)

    run_trainer()
    generate_parsed_logs()
    (training_details, validation_details) = parse_logs()
    # TODO(neuberg): This will need to be adapted against an already trained weight
    # file that we are fine-tuning.
    trained_weight_file = get_trained_weight_file()

    if output_graphs:
        graph.plot_results(training_details, validation_details, note)

        # If no weight file is provided by callers to this method, parse out the one we just
        # trained.
        if weight_file == None:
            weight_file = trained_weight_file
        predict.test_validation(data, weight_file)
예제 #6
0
파일: test.py 프로젝트: yemenr/cloudless
def parse_command_line():
    parser = argparse.ArgumentParser(
        description="""Tests a trained Caffe model to see how well
        it does, generating quality graphs and statistics""")
    parser.add_argument("--log_path",
                        help="The path to where to place log files and graphs",
                        type=str,
                        default="logs")
    parser.add_argument(
        "--log_num",
        help="""Number that will be appended to log files; this will
        be automatically padded and added with zeros, such as output00001.log""",
        type=int,
        default=1)
    parser.add_argument(
        "--input_weight_file",
        help="""The trained and fine-tuned Caffe model that
        we will be testing; defaults to the last trained model from train.py""",
        type=str,
        default="logs/latest_bvlc_alexnet_finetuned.caffemodel")
    parser.add_argument("--note",
                        help="Adds extra note onto generated quality graphs.",
                        type=str,
                        default="")
    parser.add_argument("--solver",
                        help="The path to our Caffe solver prototxt file",
                        type=str,
                        default="src/caffe_model/bvlc_alexnet/solver.prototxt")
    parser.add_argument(
        "--deploy",
        help="""Path to our Caffe deploy/inference time prototxt file""",
        type=str,
        default="src/caffe_model/bvlc_alexnet/deploy.prototxt")
    parser.add_argument("--threshold",
                        help="""The percentage threshold over which we assume
        something is a cloud. Note that this value is from 0.0 to 100.0""",
                        type=float,
                        default=0.1)
    parser.add_argument(
        "--validation_leveldb",
        help="""Path to where the validation leveldb file is""",
        type=str,
        default="data/leveldb/validation_leveldb")
    parser.add_argument("--width",
                        help="Width of image during training",
                        type=int,
                        default=256)
    parser.add_argument("--height",
                        help="Height of image during training",
                        type=int,
                        default=256)
    parser.add_argument("--inference_width",
                        help="Width of image during training",
                        type=int,
                        default=227)
    parser.add_argument("--inference_height",
                        help="Height of image during training",
                        type=int,
                        default=227)
    parser.add_argument("--training_mean_pickle",
                        help="Path to pickled mean values",
                        type=str,
                        default="data/imagenet/imagenet_mean.npy")

    args = vars(parser.parse_args())

    print "Testing trained model..."

    caffe_home = utils.assert_caffe_setup()

    # Ensure the random number generator always starts from the same place for consistent tests.
    random.seed(0)

    log_path = os.path.abspath(args["log_path"])
    log_num = args["log_num"]
    (output_ending, output_log_prefix,
     output_log_file) = utils.get_log_path_details(log_path, log_num)
    output_graph_path = output_log_prefix

    (training_details,
     validation_details) = utils.parse_logs(log_path, output_log_file)

    plot_results(training_details, validation_details, args["note"],
                 output_graph_path, args["solver"])
    validation_leveldb = os.path.abspath(args["validation_leveldb"])
    deploy = os.path.abspath(args["deploy"])
    input_weight_file = os.path.abspath(args["input_weight_file"])
    training_mean_pickle = os.path.abspath(args["training_mean_pickle"])
    predict.test_validation(args["threshold"], output_log_prefix,
                            validation_leveldb, deploy, args["width"],
                            args["height"], args["inference_width"],
                            args["inference_height"], input_weight_file,
                            training_mean_pickle)