Ejemplo n.º 1
0
def score(
        result_folder,
        epoch=None,
        use_cpu=False):
    """Test a network on the dataset."""
    if use_cpu:
        bnet.set_mode_cpu()
    else:
        bnet.set_mode_gpu()
    _LOGGER.info("Loading data...")
    tr_data, _ = training_data()
    te_data, te_labels = test_data()
    from data import _MEAN
    _LOGGER.info("Loading network...")
    # Load the model.
    model, _, _, _ = _model(result_folder,
                            tr_data.shape[0],
                            epoch=epoch,
                            no_solver=True)
    _LOGGER.info("Predicting...")
    results = model.predict(te_data,
                            test_callbacks=[
                                RandCropMonitor('data', _MEAN),
                                mnt.ProgressIndicator()
                            ],
                            out_blob_names=['score'])
    _LOGGER.info("Accuracy: %f.",
                 accuracy_score(te_labels,
                                np.argmax(np.array(results), axis=1)))
Ejemplo n.º 2
0
def test_image(
        result_folder,
        epoch=None,
        image_idx=0,
        use_cpu=False):
    """Test a network on one test image."""
    if use_cpu:
        bnet.set_mode_cpu()
    else:
        bnet.set_mode_gpu()
    _LOGGER.info("Loading data...")
    tr_data, _ = training_data()
    te_data, _ = test_data()
    from data import _MEAN
    _LOGGER.info("Loading network...")
    # Load the model for training.
    model, _, _, _ = _model(result_folder,
                            tr_data.shape[0],
                            epoch=epoch)
    _LOGGER.info("Predicting...")
    results = model.predict(te_data[:image_idx + 1],
                            test_callbacks=[
                                RandCropMonitor('data', _MEAN),
                                mnt.ProgressIndicator()
                            ],
                            out_blob_names=['score'])
    _LOGGER.info("Prediction for image %d: %s.",
                 image_idx, str(results[image_idx]))
Ejemplo n.º 3
0
def test_image(result_folder, epoch=None, image_idx=0, use_cpu=False):
    """Test a network on one test image."""
    if use_cpu:
        bnet.set_mode_cpu()
    else:
        bnet.set_mode_gpu()
    _LOGGER.info("Loading data...")
    tr_data, _ = training_data()
    te_data, _ = test_data()
    _LOGGER.info("Loading network...")
    # Load the model for training.
    model, _, _, _ = _model(result_folder, tr_data.shape[0], epoch=epoch)
    _LOGGER.info("Predicting...")
    results = model.predict(te_data, test_callbacks=[mnt.ProgressIndicator()])
    _LOGGER.info("Prediction for image %d: %s.", image_idx,
                 str(results[image_idx]))
Ejemplo n.º 4
0
def test_image(
        result_folder,
        epoch=None,
        image_idx=0,
        use_cpu=False):
    """Test a network on one test image."""
    if use_cpu:
        bnet.set_mode_cpu()
    else:
        bnet.set_mode_gpu()
    _LOGGER.info("Loading data...")
    tr_data, _ = training_data()
    te_data, _ = test_data()
    _LOGGER.info("Loading network...")
    # Load the model for training.
    model, _, _, _ = _model(result_folder,
                            tr_data.shape[0],
                            epoch=epoch)
    _LOGGER.info("Predicting...")
    results = model.predict(te_data,
                            test_callbacks=[mnt.ProgressIndicator()])
    _LOGGER.info("Prediction for image %d: %s.",
                 image_idx, str(results[image_idx]))