weecology / DeepForest

Python Package for Airborne RGB machine learning
https://deepforest.readthedocs.io/
MIT License
521 stars 176 forks source link

There is no reason to ask for the height, width on plot_results. #834

Open bw4sz opened 1 week ago

bw4sz commented 1 week ago

If the data is well formatted.

gdf.head()
   id                                            polygon  ...                  source                                           geometry
0   1  POLYGON ((79 683,78 684,77 684,76 685,75 686,7...  ...  Justdiggit et al. 2023  POLYGON ((79 683, 78 684, 77 684, 76 685, 75 6...
1   2  POLYGON ((275 323,274 324,273 324,272 324,271 ...  ...  Justdiggit et al. 2023  POLYGON ((275 323, 274 324, 273 324, 272 324, ...
2   3  POLYGON ((197 239,196 240,195 240,194 240,194 ...  ...  Justdiggit et al. 2023  POLYGON ((197 239, 196 240, 195 240, 194 240, ...
3   4  POLYGON ((996 465,995 466,994 467,993 466,992 ...  ...  Justdiggit et al. 2023  POLYGON ((996 465, 995 466, 994 467, 993 466, ...
4   5  POLYGON ((934 582,933 583,932 584,931 584,930 ...  ...  Justdiggit et al. 2023  POLYGON ((934 582, 933 583, 932 584, 931 584, ...

[5 rows x 6 columns]
gdf.root_dir
'/orange/ewhite/DeepForest/justdiggit-drone/label_sample/'
    plot_results(gdf)
Traceback (most recent call last):
  File "/blue/ewhite/b.weinstein/miniconda3/envs/MillionTrees/lib/python3.10/site-packages/deepforest/visualize.py", line 433, in plot_results
    annotated_scene = _plot_image_with_results(df=results,
  File "/blue/ewhite/b.weinstein/miniconda3/envs/MillionTrees/lib/python3.10/site-packages/deepforest/visualize.py", line 485, in _plot_image_with_results
    detections = convert_to_sv_format(df, height=height, width=width)
  File "/blue/ewhite/b.weinstein/miniconda3/envs/MillionTrees/lib/python3.10/site-packages/deepforest/visualize.py", line 323, in convert_to_sv_format
    raise ValueError(
ValueError: height and width of the mask must be provided for polygon predictions

to fix, just go and get the height and width within the function, everything is there.