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

Custom tiles on Colab error AttributeError: 'int' object has no attribute 'geometry' #71

Open
kavitak123 opened this issue Sep 7, 2024 · 7 comments

Comments

@kavitak123
Copy link

Hi,
I have been using colab_example.ipynb with custom tiles with location Frisco,Texas . I have tiles of zoom level 18.
python -m tile2net generate -l "33.155490, -96.822725, 33.15390, -96.824725" -i "/content/frisco/18/18/x/y.png" -z 18 -n frisco_test_1 -o "/content/frisco/18/" | python -m tile2net inference

I get the following error . I appreciate if anyone can look into this and let me know the fix.
INFO Created 22 records
INFO Polygons are generated and saved!
INFO Starting network creation...
100% 9/9 [00:00<00:00, 1060.51it/s]
100% 9/9 [00:00<00:00, 653.93it/s]
INFO ..... creating the processed sidewalk network
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 "/content/tile2net/src/tile2net/main.py", line 6, in
argh.dispatch_commands([
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 358, in dispatch_commands
dispatch(parser, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 183, in dispatch
for line in lines:
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 294, in _execute_command
for line in result:
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 247, in _call
result = function(namespace_obj)
File "/content/tile2net/src/tile2net/namespace.py", line 671, in wrapper
return func(namespace, **kwargs)
File "/content/tile2net/src/tile2net/tileseg/inference/inference.py", line 510, in inference
return inference.inference()
File "/content/tile2net/src/tile2net/tileseg/inference/inference.py", line 198, in inference
self.validate(
File "/content/tile2net/src/tile2net/tileseg/inference/inference.py", line 313, in validate
net.convert_whole_poly2line()
File "/content/tile2net/src/tile2net/raster/pednet.py", line 338, in convert_whole_poly2line
points = get_line_sepoints(self.crosswalk)
File "/content/tile2net/src/tile2net/raster/tile_utils/topology.py", line 117, in get_line_sepoints
linegeom = line_gdf.geometry.values
AttributeError: 'int' object has no attribute 'geometry'

Thanks,
K

@dhodcz2
Copy link
Collaborator

dhodcz2 commented Sep 8, 2024

Thank you for using our library. This error indicates that the tiles you had provided did not seem to generate any crosswalk networks. I have updated the repository to return an empty GeoDataFrame in this case. Please use git checkout dhodcz2 to get the latest changes and see if it works for you now.

@kavitak123
Copy link
Author

Thank you very much for your response and fixing the error.
I am getting the source data from https://earthexplorer.usgs.gov/scene/metadata/full/5e83a2397d63a400/3889237_339650320150202/

Ran with the following coordinates with zoom level 18
!python -m tile2net generate -l "33.156330, -96.831250, 33.144617, -96.817775" -i "/content/frisco/18/18/x/y.png" -z 18
-n frisco_test_1 -o "/content/frisco/18/output3" | python -m tile2net inference

Screenshot 2024-09-08 at 11 39 53
Screenshot 2024-09-08 at 11 40 06

Screenshot 2024-09-08 at 11 40 35

The network plots the roads not the sidewalks

Tried with zoom level 19 , same coordinates , get the below error.

!python -m tile2net generate -l "33.156330, -96.831250, 33.144617, -96.817775" -i "/content/drive/MyDrive/frisco/19/19/x/y.png" -z 19 -n frisco_test_1 -o "/content/drive/MyDrive/frisco/19/output3" | python -m tile2net inference

INFO Starting network creation...
100% 126/126 [00:00<00:00, 2845.60it/s]
100% 126/126 [00:00<00:00, 1732.02it/s]
INFO ..... creating the processed sidewalk network
/content/tile2net/src/tile2net/raster/pednet.py:222: UserWarning: No crosswalks found
warnings.warn('No crosswalks found')
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 "/content/tile2net/src/tile2net/main.py", line 6, in
argh.dispatch_commands([
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 358, in dispatch_commands
dispatch(parser, *args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 183, in dispatch
for line in lines:
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 294, in _execute_command
for line in result:
File "/usr/local/lib/python3.10/dist-packages/argh/dispatching.py", line 247, in _call
result = function(namespace_obj)
File "/content/tile2net/src/tile2net/namespace.py", line 671, in wrapper
return func(namespace, **kwargs)
File "/content/tile2net/src/tile2net/tileseg/inference/inference.py", line 510, in inference
return inference.inference()
File "/content/tile2net/src/tile2net/tileseg/inference/inference.py", line 198, in inference
self.validate(
File "/content/tile2net/src/tile2net/tileseg/inference/inference.py", line 313, in validate
net.convert_whole_poly2line()
File "/content/tile2net/src/tile2net/raster/pednet.py", line 349, in convert_whole_poly2line
points = get_line_sepoints(self.crosswalk)
File "/content/tile2net/src/tile2net/raster/tile_utils/topology.py", line 131, in get_line_sepoints
points = vectorize_points(np.unique(coords[edges], axis=0))
File "/content/tile2net/src/tile2net/raster/tile_utils/topology.py", line 141, in vectorize_points
return np.apply_along_axis(Point, 1, lst)
File "/usr/local/lib/python3.10/dist-packages/numpy/lib/shape_base.py", line 376, in apply_along_axis
raise ValueError(
ValueError: Cannot apply_along_axis when any iteration dimensions are 0

Please suggest what can be done to get proper results.

@paulterinho
Copy link

@kavitak123 It could be that the tile2net's ML model needs to be fine-tuned for your particular area (San Fransisco?). San Fran morphologically might be very different feature-wise than NYC.

@Mary-h86
Copy link
Member

@kavitak123 Thanks for sharing your results with us.

I ran the model on your area as well and reviewed the output. As @paulterinho pointed out, the key issue lies in the model’s current training data. The model was primarily trained on high-density, urbanized areas along the East Coast of the US, where footpaths are typically paved areas within parks and trails surrounded by greenery. As a result, the model tends to predict such surfaces as sidewalks, leading to the incorrect classification of most local roads in your area as footpaths (sidewalks).

We’re aware of this limitation, and it’s something we’re actively addressing in the upcoming version of the model. The new version will be trained on lower-density, suburban areas, which should significantly improve performance for regions like yours.

@paulterinho
Copy link

@Mary-h86 Is there documentation on how we can fine-tune this model for our respective locales? (Even if you could point us to a general framework's documentation, would be useful. )

@Mary-h86
Copy link
Member

@paulterinho The training code is not made publicly available, however, we will publish the new model trained on the lower-density areas once it is ready. Jut note that fine-tuning the model requires high-quality pixel-wise annotated images (which is most of the time the main bottleneck).

@paulterinho
Copy link

@Mary-h86 Thanks for the update, and understood. Best of luck with the project!

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

No branches or pull requests

4 participants