Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: shapefile_to_annotations() got an unexpected keyword argument 'convert_to_boxes' #643

Closed
JoseFRuiz opened this issue Mar 29, 2024 · 3 comments · Fixed by #644
Closed

Comments

@JoseFRuiz
Copy link

JoseFRuiz commented Mar 29, 2024

Describe the bug
I am following the instructions to turn a shapefile into a dataframe of bounding box annotations but there is a problem with the parameter "convert_to_boxes"

To Reproduce

from deepforest.utilities import shapefile_to_annotations
df = shapefile_to_annotations(
    shapefile=os.path.join(os.getcwd(),'..','training_labels','imgname.shp'), 
    rgb=os.path.join(os.getcwd(),'..','training_data','imgname.png'),
    convert_to_boxes=True, buffer_size=0.15
)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[20], line 1
----> 1 df = shapefile_to_annotations(
      2     shapefile=os.path.join(os.getcwd(),'..','training_labels','imgname.shp'), 
      3     rgb=os.path.join(os.getcwd(),'..','training_data','imgname.png'),
      4     convert_to_boxes=True, buffer_size=0.15
      5 )

TypeError: shapefile_to_annotations() got an unexpected keyword argument 'convert_to_boxes'

Environment (please complete the following information):

  • OS: Windows 10
  • Python version and environment : Python 3.11.2, Conda
@JoseFRuiz
Copy link
Author

JoseFRuiz commented Mar 29, 2024

I just realized that instead of "convert_to_boxes=True", I have to use "geometry_type='point'", but I got a new error:

File ~\anaconda3\envs\myenv\Lib\site-packages\deepforest\utilities.py:299, in shapefile_to_annotations(shapefile, rgb, buffer_size, geometry_type, savedir)
    296     raster_crs = src.crs
    298 # Check matching the crs
--> 299 if not gdf.crs.to_string() == raster_crs.to_string():
    300     raise ValueError("The shapefile crs {} does not match the image crs {}".format(
    301         gdf.crs, src.crs))
    303 # Transform project coordinates to image coordinates

AttributeError: 'NoneType' object has no attribute 'to_string'

@bw4sz
Copy link
Collaborator

bw4sz commented Mar 29, 2024

Thanks for the issue. Point annotations are still pretty new, i'm not surprised. What's happening here is that we expected everyone with point annotations to have projected data. Your data must not have a CRS. In general, point annotations are not well supported until this PR is merged

#590

which won't be for a couple months.

I can fix this issue quickly, but in general we suggest you annotate boxes, not points until this area is more mature.

@JoseFRuiz
Copy link
Author

Got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants