Closed youngdjn closed 10 months ago
I would like to work on this issue. Can you guide me on how to get started with it?
Yes, this additional line of code is needed, but i'm not convinced that's the problem. I think its that boxes_to_shapefile should take in the path to the RGB object and forget about the silly root dir (#512). I think this would be more explicit.
from deepforest import main
from deepforest import get_data
from deepforest import utilities
import os
import rasterio as rio
import numpy as np
raster_path = get_data("OSBS_029.tif")
r = rio.open(raster_path)
df = r.read()
rolled_df = np.rollaxis(df, 0,3)
m = main.deepforest()
m.use_release()
boxes = m.predict_tile(image=rolled_df, patch_size=1500)
shp = utilities.boxes_to_shapefile(boxes, rgb=raster_path, projected=True)
shp.to_file("/home/exouser/Downloads/boxes.gpkg")
This way the boxes_to_shapefile function isn't making any assumptions about what columns are in 'boxes' for finding the rgb image. Let's close this issue and make a new one focused on that.
Describe the bug To save the predicted tree boxes to shapefile using
boxes_to_shapefile
, the boxes df produced bypredict_tile
needs to have a columnimage_path
, but it doesn't. I'm using the recent update intended to fix this, but it's still not working. (The updated code looks good to my inexperienced python eye so I'm stumped.) I can manually add the image path withboxes["image_path"] = os.path.basename("/path/to/ortho.tif")
and thenboxes_to_shapefile
works.To Reproduce I insalled deepforest from github after the PR was merged:
pip install git+https://github.com/weecology/DeepForest.git
To use the orthomosaic I have been using, download it from here: https://ucdavis.box.com/s/f6ddi0hzvtd5hq11bgp9l91fyjaydwlf
Then run my full script but change the ortho directory to where you downloaded it to:
Environment (please complete the following information):