Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def config():
config = utilities.read_config(get_data("deepforest_config.yml"))
return config
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
def __init__(self, weights=None, saved_model=None):
self.weights = weights
self.saved_model = saved_model
#Read config file - if a config file exists in local dir use it, if not use installed.
if os.path.exists("deepforest_config.yml"):
config_path = "deepforest_config.yml"
else:
try:
config_path = get_data("deepforest_config.yml")
except Exception as e:
raise ValueError("No deepforest_config.yml found either in local directory or in installed package location. {}".format(e))
print("Reading config file: {}".format(config_path))
self.config = utilities.read_config(config_path)
#release version id to flag if release is being used
self.__release_version__ = None
#Load saved model if needed
if self.saved_model:
print("Loading saved model")
#Capture user warning, not relevant here
with warnings.catch_warnings():
warnings.filterwarnings("ignore",category=UserWarning)
self.model = utilities.load_model(saved_model)
self.prediction_model = convert_model(self.model)
if self.weights is not None:
print("Creating model from weights")
backbone = models.backbone(self.config["backbone"])