Skip to content

Commit

Permalink
style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bw4sz committed Oct 7, 2023
1 parent efdf813 commit d527c4b
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 63 deletions.
10 changes: 8 additions & 2 deletions deepforest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import warnings
import importlib


class deepforest(pl.LightningModule):
"""Class for training and predicting tree crowns in RGB images
"""

def __init__(self,
num_classes: int = 1,
label_dict: dict = {"Tree": 0},
Expand Down Expand Up @@ -64,7 +66,9 @@ def __init__(self,

# If num classes is specified, overwrite config
if not num_classes == 1:
warnings.warn("Directly specifying the num_classes arg in deepforest.main will be deprecated in 2.0 in favor of config_args. Use deepforest.main(config_args={'num_classes':value})")
warnings.warn(
"Directly specifying the num_classes arg in deepforest.main will be deprecated in 2.0 in favor of config_args. Use deepforest.main(config_args={'num_classes':value})"
)

#Create a default trainer.
self.create_trainer()
Expand Down Expand Up @@ -100,7 +104,9 @@ def use_release(self, check_release=True):
release_tag, self.release_state_dict = utilities.use_release(
check_release=check_release)
if self.config["architecture"] is not "retinanet":
warnings.warn("The config file specifies architecture {}, but the release model is torchvision retinanet. Reloading with deepforest.main with a retinanet model".format(self.config["architecture"]))
warnings.warn(
"The config file specifies architecture {}, but the release model is torchvision retinanet. Reloading with deepforest.main with a retinanet model"
.format(self.config["architecture"]))
self.config["architecture"] = "retinanet"
self.create_model()
self.model.load_state_dict(torch.load(self.release_state_dict))
Expand Down
220 changes: 159 additions & 61 deletions tests/data/OSBS_029.csv
Original file line number Diff line number Diff line change
@@ -1,62 +1,160 @@
image_path,xmin,ymin,xmax,ymax,label
OSBS_029.tif,203,67,227,90,Tree
OSBS_029.tif,256,99,288,140,Tree
OSBS_029.tif,166,253,225,304,Tree
OSBS_029.tif,365,2,400,27,Tree
OSBS_029.tif,312,13,349,47,Tree
OSBS_029.tif,365,21,400,70,Tree
OSBS_029.tif,278,1,312,37,Tree
OSBS_029.tif,364,204,400,246,Tree
OSBS_029.tif,90,117,121,145,Tree
OSBS_029.tif,115,109,150,152,Tree
OSBS_029.tif,161,155,199,191,Tree
OSBS_029.tif,120,153,160,192,Tree
OSBS_029.tif,349,290,375,320,Tree
OSBS_029.tif,1,153,53,217,Tree
OSBS_029.tif,1,218,41,254,Tree
OSBS_029.tif,65,143,117,190,Tree
OSBS_029.tif,368,78,400,110,Tree
OSBS_029.tif,149,95,203,156,Tree
OSBS_029.tif,154,195,190,229,Tree
OSBS_029.tif,103,195,153,244,Tree
OSBS_029.tif,49,377,75,400,Tree
OSBS_029.tif,116,367,151,400,Tree
OSBS_029.tif,234,243,253,267,Tree
OSBS_029.tif,292,367,337,400,Tree
OSBS_029.tif,333,336,374,384,Tree
OSBS_029.tif,1,13,39,62,Tree
OSBS_029.tif,1,65,40,106,Tree
OSBS_029.tif,50,3,102,57,Tree
OSBS_029.tif,102,36,130,68,Tree
OSBS_029.tif,156,5,180,38,Tree
OSBS_029.tif,186,1,231,40,Tree
OSBS_029.tif,382,260,400,305,Tree
OSBS_029.tif,331,128,363,161,Tree
OSBS_029.tif,332,84,360,118,Tree
OSBS_029.tif,363,115,393,146,Tree
OSBS_029.tif,117,263,149,307,Tree
OSBS_029.tif,100,309,155,371,Tree
OSBS_029.tif,179,359,214,398,Tree
OSBS_029.tif,199,340,231,374,Tree
OSBS_029.tif,177,308,214,343,Tree
OSBS_029.tif,239,306,279,342,Tree
OSBS_029.tif,275,332,310,374,Tree
OSBS_029.tif,53,192,90,238,Tree
OSBS_029.tif,115,64,151,103,Tree
OSBS_029.tif,53,69,96,117,Tree
OSBS_029.tif,263,243,289,282,Tree
OSBS_029.tif,331,42,369,87,Tree
OSBS_029.tif,252,47,283,87,Tree
OSBS_029.tif,291,89,333,138,Tree
OSBS_029.tif,288,136,315,167,Tree
OSBS_029.tif,203,88,247,139,Tree
OSBS_029.tif,257,198,289,232,Tree
OSBS_029.tif,31,341,58,372,Tree
OSBS_029.tif,19,368,52,400,Tree
OSBS_029.tif,1,261,31,296,Tree
OSBS_029.tif,73,241,113,287,Tree
OSBS_029.tif,60,292,96,332,Tree
OSBS_029.tif,89,362,114,390,Tree
OSBS_029.tif,236,132,253,152,Tree
OSBS_029.tif,316,174,346,214,Tree
OSBS_029.tif,220,208,251,244,Tree
OSBS_029_0.png,90,117,121,145,Tree
OSBS_029_0.png,115,109,150,152,Tree
OSBS_029_0.png,161,155,199,191,Tree
OSBS_029_0.png,120,153,160,192,Tree
OSBS_029_0.png,1,153,53,200,Tree
OSBS_029_0.png,65,143,117,190,Tree
OSBS_029_0.png,149,95,200,156,Tree
OSBS_029_0.png,154,195,190,200,Tree
OSBS_029_0.png,1,13,39,62,Tree
OSBS_029_0.png,1,65,40,106,Tree
OSBS_029_0.png,50,3,102,57,Tree
OSBS_029_0.png,102,36,130,68,Tree
OSBS_029_0.png,156,5,180,38,Tree
OSBS_029_0.png,186,1,200,40,Tree
OSBS_029_0.png,53,192,90,200,Tree
OSBS_029_0.png,115,64,151,103,Tree
OSBS_029_0.png,53,69,96,117,Tree
OSBS_029_1.png,166,103,200,154,Tree
OSBS_029_1.png,161,5,199,41,Tree
OSBS_029_1.png,120,3,160,42,Tree
OSBS_029_1.png,1,3,53,67,Tree
OSBS_029_1.png,1,68,41,104,Tree
OSBS_029_1.png,65,0,117,40,Tree
OSBS_029_1.png,154,45,190,79,Tree
OSBS_029_1.png,103,45,153,94,Tree
OSBS_029_1.png,117,113,149,157,Tree
OSBS_029_1.png,100,159,155,200,Tree
OSBS_029_1.png,199,190,200,200,Tree
OSBS_029_1.png,177,158,200,193,Tree
OSBS_029_1.png,53,42,90,88,Tree
OSBS_029_1.png,31,191,58,200,Tree
OSBS_029_1.png,1,111,31,146,Tree
OSBS_029_1.png,73,91,113,137,Tree
OSBS_029_1.png,60,142,96,182,Tree
OSBS_029_2.png,166,53,200,104,Tree
OSBS_029_2.png,1,18,41,54,Tree
OSBS_029_2.png,154,0,190,29,Tree
OSBS_029_2.png,103,0,153,44,Tree
OSBS_029_2.png,49,177,75,200,Tree
OSBS_029_2.png,116,167,151,200,Tree
OSBS_029_2.png,117,63,149,107,Tree
OSBS_029_2.png,100,109,155,171,Tree
OSBS_029_2.png,179,159,200,198,Tree
OSBS_029_2.png,199,140,200,174,Tree
OSBS_029_2.png,177,108,200,143,Tree
OSBS_029_2.png,53,0,90,38,Tree
OSBS_029_2.png,31,141,58,172,Tree
OSBS_029_2.png,19,168,52,200,Tree
OSBS_029_2.png,1,61,31,96,Tree
OSBS_029_2.png,73,41,113,87,Tree
OSBS_029_2.png,60,92,96,132,Tree
OSBS_029_2.png,89,162,114,190,Tree
OSBS_029_3.png,53,67,77,90,Tree
OSBS_029_3.png,106,99,138,140,Tree
OSBS_029_3.png,162,13,199,47,Tree
OSBS_029_3.png,128,1,162,37,Tree
OSBS_029_3.png,11,155,49,191,Tree
OSBS_029_3.png,0,153,10,192,Tree
OSBS_029_3.png,0,95,53,156,Tree
OSBS_029_3.png,4,195,40,200,Tree
OSBS_029_3.png,6,5,30,38,Tree
OSBS_029_3.png,36,1,81,40,Tree
OSBS_029_3.png,181,128,200,161,Tree
OSBS_029_3.png,182,84,200,118,Tree
OSBS_029_3.png,0,64,1,103,Tree
OSBS_029_3.png,181,42,200,87,Tree
OSBS_029_3.png,102,47,133,87,Tree
OSBS_029_3.png,141,89,183,138,Tree
OSBS_029_3.png,138,136,165,167,Tree
OSBS_029_3.png,53,88,97,139,Tree
OSBS_029_3.png,107,198,139,200,Tree
OSBS_029_3.png,86,132,103,152,Tree
OSBS_029_3.png,166,174,196,200,Tree
OSBS_029_4.png,16,103,75,154,Tree
OSBS_029_4.png,11,5,49,41,Tree
OSBS_029_4.png,0,3,10,42,Tree
OSBS_029_4.png,199,140,200,170,Tree
OSBS_029_4.png,4,45,40,79,Tree
OSBS_029_4.png,84,93,103,117,Tree
OSBS_029_4.png,183,186,200,200,Tree
OSBS_029_4.png,181,0,200,11,Tree
OSBS_029_4.png,49,190,81,200,Tree
OSBS_029_4.png,27,158,64,193,Tree
OSBS_029_4.png,89,156,129,192,Tree
OSBS_029_4.png,125,182,160,200,Tree
OSBS_029_4.png,113,93,139,132,Tree
OSBS_029_4.png,138,0,165,17,Tree
OSBS_029_4.png,107,48,139,82,Tree
OSBS_029_4.png,86,0,103,2,Tree
OSBS_029_4.png,166,24,196,64,Tree
OSBS_029_4.png,70,58,101,94,Tree
OSBS_029_5.png,16,53,75,104,Tree
OSBS_029_5.png,199,90,200,120,Tree
OSBS_029_5.png,4,0,40,29,Tree
OSBS_029_5.png,0,167,1,200,Tree
OSBS_029_5.png,84,43,103,67,Tree
OSBS_029_5.png,142,167,187,200,Tree
OSBS_029_5.png,183,136,200,184,Tree
OSBS_029_5.png,29,159,64,198,Tree
OSBS_029_5.png,49,140,81,174,Tree
OSBS_029_5.png,27,108,64,143,Tree
OSBS_029_5.png,89,106,129,142,Tree
OSBS_029_5.png,125,132,160,174,Tree
OSBS_029_5.png,113,43,139,82,Tree
OSBS_029_5.png,107,0,139,32,Tree
OSBS_029_5.png,166,0,196,14,Tree
OSBS_029_5.png,70,8,101,44,Tree
OSBS_029_6.png,3,67,27,90,Tree
OSBS_029_6.png,56,99,88,140,Tree
OSBS_029_6.png,165,2,200,27,Tree
OSBS_029_6.png,112,13,149,47,Tree
OSBS_029_6.png,165,21,200,70,Tree
OSBS_029_6.png,78,1,112,37,Tree
OSBS_029_6.png,168,78,200,110,Tree
OSBS_029_6.png,0,1,31,40,Tree
OSBS_029_6.png,131,128,163,161,Tree
OSBS_029_6.png,132,84,160,118,Tree
OSBS_029_6.png,163,115,193,146,Tree
OSBS_029_6.png,131,42,169,87,Tree
OSBS_029_6.png,52,47,83,87,Tree
OSBS_029_6.png,91,89,133,138,Tree
OSBS_029_6.png,88,136,115,167,Tree
OSBS_029_6.png,3,88,47,139,Tree
OSBS_029_6.png,57,198,89,200,Tree
OSBS_029_6.png,36,132,53,152,Tree
OSBS_029_6.png,116,174,146,200,Tree
OSBS_029_7.png,0,103,25,154,Tree
OSBS_029_7.png,164,54,200,96,Tree
OSBS_029_7.png,149,140,175,170,Tree
OSBS_029_7.png,34,93,53,117,Tree
OSBS_029_7.png,133,186,174,200,Tree
OSBS_029_7.png,182,110,200,155,Tree
OSBS_029_7.png,131,0,163,11,Tree
OSBS_029_7.png,0,190,31,200,Tree
OSBS_029_7.png,0,158,14,193,Tree
OSBS_029_7.png,39,156,79,192,Tree
OSBS_029_7.png,75,182,110,200,Tree
OSBS_029_7.png,63,93,89,132,Tree
OSBS_029_7.png,88,0,115,17,Tree
OSBS_029_7.png,57,48,89,82,Tree
OSBS_029_7.png,36,0,53,2,Tree
OSBS_029_7.png,116,24,146,64,Tree
OSBS_029_7.png,20,58,51,94,Tree
OSBS_029_8.png,0,53,25,104,Tree
OSBS_029_8.png,164,4,200,46,Tree
OSBS_029_8.png,149,90,175,120,Tree
OSBS_029_8.png,34,43,53,67,Tree
OSBS_029_8.png,92,167,137,200,Tree
OSBS_029_8.png,133,136,174,184,Tree
OSBS_029_8.png,182,60,200,105,Tree
OSBS_029_8.png,0,159,14,198,Tree
OSBS_029_8.png,0,140,31,174,Tree
OSBS_029_8.png,0,108,14,143,Tree
OSBS_029_8.png,39,106,79,142,Tree
OSBS_029_8.png,75,132,110,174,Tree
OSBS_029_8.png,63,43,89,82,Tree
OSBS_029_8.png,57,0,89,32,Tree
OSBS_029_8.png,116,0,146,14,Tree
OSBS_029_8.png,20,8,51,44,Tree

0 comments on commit d527c4b

Please sign in to comment.