예제 #1
0
def background_train(ibs,
                     species,
                     train_gid_set=None,
                     global_limit=500000,
                     **kwargs):
    from ibeis_cnn.ingest_ibeis import get_background_training_patches2
    from ibeis_cnn.process import numpy_processed_directory2
    from ibeis_cnn.models.background import train_background
    from ibeis_cnn.utils import save_model
    data_path = join(ibs.get_cachedir(), 'extracted')
    extracted_path = get_background_training_patches2(
        ibs,
        species,
        data_path,
        patch_size=50,
        train_gid_set=train_gid_set,
        global_limit=global_limit,
        **kwargs)
    id_file, X_file, y_file = numpy_processed_directory2(extracted_path)
    output_path = join(ibs.get_cachedir(), 'training', 'background')
    model_path = train_background(output_path, X_file, y_file)
    model_state = ut.load_cPkl(model_path)
    assert 'species' not in model_state
    model_state['species'] = species
    save_model(model_state, model_path)
    return model_path
예제 #2
0
def labeler_train_ibeis_cnn(ibs,
                            species_list=None,
                            species_mapping=None,
                            viewpoint_mapping=None,
                            **kwargs):
    from ibeis_cnn.ingest_ibeis import get_cnn_labeler_training_images
    from ibeis_cnn.process import numpy_processed_directory2
    from ibeis_cnn.models.labeler import train_labeler
    from ibeis_cnn.utils import save_model
    data_path = join(ibs.get_cachedir(), 'extracted')
    extracted_path = get_cnn_labeler_training_images(
        ibs,
        data_path,
        category_list=species_list,
        category_mapping=species_mapping,
        viewpoint_mapping=viewpoint_mapping,
        **kwargs)
    id_file, X_file, y_file = numpy_processed_directory2(extracted_path)
    output_path = join(ibs.get_cachedir(), 'training', 'labeler')
    model_path = train_labeler(output_path, X_file, y_file)
    # Add the species_list to the model
    model_state = ut.load_cPkl(model_path)
    assert 'category_list' not in model_state
    model_state['category_list'] = species_list
    assert 'viewpoint_mapping' not in model_state
    model_state['viewpoint_mapping'] = viewpoint_mapping
    save_model(model_state, model_path)
    return model_path
예제 #3
0
def classifier_cameratrap_train(ibs, positive_imageset_id,
                                negative_imageset_id, **kwargs):
    from ibeis_cnn.ingest_ibeis import get_cnn_classifier_cameratrap_binary_training_images
    from ibeis_cnn.process import numpy_processed_directory2
    from ibeis_cnn.models.classifier import train_classifier
    data_path = join(ibs.get_cachedir(), 'extracted')
    extracted_path = get_cnn_classifier_cameratrap_binary_training_images(
        ibs,
        positive_imageset_id,
        negative_imageset_id,
        dest_path=data_path,
        **kwargs)
    id_file, X_file, y_file = numpy_processed_directory2(extracted_path)
    output_path = join(ibs.get_cachedir(), 'training', 'classifier-cameratrap')
    model_path = train_classifier(output_path, X_file, y_file)
    # Return model path
    return model_path
예제 #4
0
def classifier_binary_train(ibs, species_list, **kwargs):
    from ibeis_cnn.ingest_ibeis import get_cnn_classifier_binary_training_images
    from ibeis_cnn.process import numpy_processed_directory2
    from ibeis_cnn.models.classifier import train_classifier
    from ibeis_cnn.utils import save_model
    data_path = join(ibs.get_cachedir(), 'extracted')
    extracted_path = get_cnn_classifier_binary_training_images(
        ibs, species_list, dest_path=data_path, **kwargs)
    id_file, X_file, y_file = numpy_processed_directory2(extracted_path)
    output_path = join(ibs.get_cachedir(), 'training', 'classifier-binary')
    model_path = train_classifier(output_path, X_file, y_file)
    # Add the species_list to the model
    model_state = ut.load_cPkl(model_path)
    assert 'species_list' not in model_state
    model_state['species_list'] = species_list
    save_model(model_state, model_path)
    # Return model path
    return model_path