How to use deepforest - 10 common examples

To help you get started, we’ve selected a few deepforest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github weecology / DeepForest / tests / test_tfrecords.py View on Github external
def config():
    print("Configuring tfrecord tests")
    config = {}
    config["patch_size"] = 200
    config["patch_overlap"] = 0.05
    config["annotations_xml"] = get_data("OSBS_029.xml")
    config["rgb_dir"] = "tests/data"
    config["annotations_file"] = "tests/data/OSBS_029.csv"
    config["path_to_raster"] =get_data("OSBS_029.tif")
    config["image-min-side"] = 800
    config["backbone"] = "resnet50"
    
    #Create a clean config test data
    annotations = utilities.xml_to_annotations(xml_path=config["annotations_xml"])
    annotations.to_csv("tests/data/testtfrecords_OSBS_029.csv",index=False)
    
    annotations_file = preprocess.split_raster(path_to_raster=config["path_to_raster"],
                                                        annotations_file="tests/data/testtfrecords_OSBS_029.csv",
                                                        base_dir= "tests/data/",
                                                        patch_size=config["patch_size"],
                                                        patch_overlap=config["patch_overlap"])
github weecology / DeepForest / tests / test_deepforest.py View on Github external
def annotations():
    annotations = utilities.xml_to_annotations(get_data("OSBS_029.xml"))
    #Point at the jpg version for tfrecords
    annotations.image_path = annotations.image_path.str.replace(".tif",".jpg")
    
    annotations_file = get_data("testfile_deepforest.csv")
    annotations.to_csv(annotations_file,index=False,header=False)
    
    return annotations_file
github weecology / DeepForest / tests / test_utilities.py View on Github external
def config():
    config  = utilities.read_config(get_data("deepforest_config.yml"))
    return config
github weecology / DeepForest / tests / test_deepforest.py View on Github external
def test_predict_image(download_release):
    #Load model
    test_model = deepforest.deepforest(weights=get_data("NEON.h5"))    
    assert isinstance(test_model.model,keras.models.Model)
    
    #Predict test image and return boxes
    boxes = test_model.predict_image(image_path=get_data("OSBS_029.tif"), show=False, return_plot = False)
    
    #Returns a 6 column numpy array, xmin, ymin, xmax, ymax, score, label
    assert boxes.shape[1] == 6
github weecology / DeepForest / tests / test_utilities.py View on Github external
def test_xml_to_annotations():
    annotations = utilities.xml_to_annotations(xml_path = get_data("OSBS_029.xml"))
    print(annotations.shape)
    assert annotations.shape == (61 ,6)
    
    #bounding box extents should be int
    assert annotations["xmin"].dtype == "int"
github weecology / DeepForest / tests / test_utilities.py View on Github external
def test_use_release():
    #Download latest model from github release
    release_tag, weights = utilities.use_release()
    assert os.path.exists(get_data("NEON.h5"))
github weecology / DeepForest / tests / test_tfrecords.py View on Github external
def config():
    print("Configuring tfrecord tests")
    config = {}
    config["patch_size"] = 200
    config["patch_overlap"] = 0.05
    config["annotations_xml"] = get_data("OSBS_029.xml")
    config["rgb_dir"] = "tests/data"
    config["annotations_file"] = "tests/data/OSBS_029.csv"
    config["path_to_raster"] =get_data("OSBS_029.tif")
    config["image-min-side"] = 800
    config["backbone"] = "resnet50"
    
    #Create a clean config test data
    annotations = utilities.xml_to_annotations(xml_path=config["annotations_xml"])
    annotations.to_csv("tests/data/testtfrecords_OSBS_029.csv",index=False)
    
    annotations_file = preprocess.split_raster(path_to_raster=config["path_to_raster"],
                                                        annotations_file="tests/data/testtfrecords_OSBS_029.csv",
                                                        base_dir= "tests/data/",
                                                        patch_size=config["patch_size"],
                                                        patch_overlap=config["patch_overlap"])
    
    annotations_file.to_csv("tests/data/testfile_tfrecords.csv", index=False,header=False)
    return config
github weecology / DeepForest / tests / test_tfrecords.py View on Github external
def bad_annotations():
    annotations = utilities.xml_to_annotations(get_data("OSBS_029.xml"))
    f = "tests/data/testfile_error_deepforest.csv"
    annotations.to_csv(f,index=False,header=False)
    return f
github weecology / DeepForest / tests / test_preprocess.py View on Github external
def config():
    config = utilities.read_config(get_data("deepforest_config.yml"))
    config["patch_size"] = 200
    config["patch_overlap"] = 0.25
    config["annotations_xml"] = get_data("OSBS_029.xml")
    config["rgb_dir"] = "tests/data"
    config["annotations_file"] = "tests/data/OSBS_029.csv"
    config["path_to_raster"] = get_data("OSBS_029.tif")
    
    #Create a clean config test data
    annotations = utilities.xml_to_annotations(xml_path = config["annotations_xml"])
    annotations.to_csv("tests/data/OSBS_029.csv",index=False)
    
    return config
github weecology / DeepForest / tests / test_deepforest.py View on Github external
def download_release():
    print("running fixtures")
    utilities.use_release()