Skip to content

Commit

Permalink
Merge pull request weecology#599 from Om-Doiphode/return_plot
Browse files Browse the repository at this point in the history
Fixed error related to tile assignment
  • Loading branch information
ethanwhite authored Jan 20, 2024
2 parents c206bfe + 5c8b344 commit 7986f6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deepforest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ def predict_tile(self,
# Draw predictions on BGR
if raster_path:
tile = rio.open(raster_path).read()
else:
tile = self.image
drawn_plot = tile[:, :, ::-1]
drawn_plot = visualize.plot_predictions(tile,
results,
Expand Down
14 changes: 14 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ def test_predict_tile_from_array(m, patch_overlap, raster_path):
return_plot = False)
assert not prediction.empty

@pytest.mark.parametrize("patch_overlap",[0.1, 0])
def test_predict_tile_from_array_with_return_plot(m, patch_overlap, raster_path):
#test predict numpy image
image = np.array(Image.open(raster_path))
m.config["train"]["fast_dev_run"] = False
m.create_trainer()
prediction = m.predict_tile(image = image,
patch_size = 300,
patch_overlap = patch_overlap,
return_plot = True,
color=(0,255,0))
assert isinstance(prediction, np.ndarray)
assert prediction.size > 0

def test_predict_tile_no_mosaic(m, raster_path):
#test no mosaic, return a tuple of crop and prediction
m.config["train"]["fast_dev_run"] = False
Expand Down

0 comments on commit 7986f6b

Please sign in to comment.