VIDA-NYU / tile2net

Automated mapping of pedestrian networks from aerial imagery tiles
BSD 3-Clause "New" or "Revised" License
148 stars 23 forks source link

Errors when running example. #4

Closed jthiard closed 1 year ago

jthiard commented 1 year ago

Hi, thanks for releasing this beta version!

I just managed to install and run the example script but I needed two small fixes.

First crash :

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/__main__.py", line 7, in <module>
    argh.dispatch_commands([
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 349, in dispatch_commands
    dispatch(parser, *args, **kwargs)
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 179, in dispatch
    for line in lines:
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 290, in _execute_command
    for line in result:
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 243, in _call
    result = function(namespace_obj)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/namespace.py", line 630, in wrapper
    return func(namespace, **kwargs)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/inference/__init__.py", line 306, in inference
    run_inference()
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/inference/__init__.py", line 205, in run_inference
    validate(val_loader, net, criterion=None, optim=None, epoch=0,
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/inference/__init__.py", line 265, in validate
    dumper.dump(
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/utils/misc.py", line 371, in dump
    grid.tiles[grid.pose_dict[int(idd_)]].mask2poly(np.array(prediction_pil), img_array=True)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/raster/tile.py", line 583, in mask2poly
    swcw = geoms_sw.append(geoms_cw)
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/pandas/core/generic.py", line 5989, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'GeoDataFrame' object has no attribute 'append'. Did you mean: '_append'?

The append method does not exists in pandas 2.0 (which is installed by default as a geopandas dependency), so I installed pandas 1.5. This can be fixed by prepending

pandas<2.0

In the requirements.dev.txt file.

Second crash

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/__main__.py", line 7, in <module>
    argh.dispatch_commands([
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 349, in dispatch_commands
    dispatch(parser, *args, **kwargs)
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 179, in dispatch
    for line in lines:
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 290, in _execute_command
    for line in result:
  File "/home/jerome/envs/tile2net/lib/python3.10/site-packages/argh/dispatching.py", line 243, in _call
    result = function(namespace_obj)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/namespace.py", line 630, in wrapper
    return func(namespace, **kwargs)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/inference/__init__.py", line 306, in inference
    run_inference()
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/inference/__init__.py", line 205, in run_inference
    validate(val_loader, net, criterion=None, optim=None, epoch=0,
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/tileseg/inference/__init__.py", line 283, in validate
    grid.save_ntw_polygon()
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/raster/grid.py", line 595, in save_ntw_polygon
    unioned = buff_dfs(poly_network, crs)
  File "/home/jerome/taf/code/tile2net/src/src/tile2net/raster/tile_utils/geodata_utils.py", line 354, in buff_dfs
    gdf.geometry.to_crs(3857, inplace=True)
TypeError: GeoSeries.to_crs() got an unexpected keyword argument 'inplace'

I just commented the offending line in the code, but I'm not sure this is the right fix.

After that it ran smoothly.

Mary-h86 commented 1 year ago

Thank you very much for the detailed and to the point description of the errors! I fixed both, please do a git pull, now you can run it with pandas 2.0 as well. I will close this issue since both concerns are addressed. If the issue persists, feel free to report here!

jthiard commented 1 year ago

Thanks for the fix, I just ran the example with both pandas 1.5 & 2.0 and everything went good!

FYI we plan to do some tests in France in the coming weeks, we'll let you know if we run into some issues, and share some results.

Mary-h86 commented 1 year ago

Thank you! That sounds exciting, I am definitely looking forward to seeing the results. When you want to use your own set of tiles, please note:

1- make sure your image data conforms with the specifications here 2- To run tile2net generate on your set of images, you need to pass the --input parameter, with the path to your image folder 3- Note that the model is trained on the US cities, so to have the best performance, you may require fine-tuning.

In case you encounter any problems, we are here to help!