VIDA-NYU / tile2net

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

issue with inference module running on tiles with crs 3857 #61

Closed ahmademami97 closed 3 months ago

ahmademami97 commented 3 months ago

Hi, I'm currently handling aerial images in CRS 3857. While defining rasters with the generate function and specifying CRS parameters for the module, I'm encountering errors halfway through the inference process on my tiles. What could be triggering these errors? Are there potential oversights on my end? Interestingly, when I omit the CRS parameter and leave it as default, the inference proceeds smoothly, albeit with slightly misaligned results. here is an image of the results i got on a small image in sydney, australia

image
dhodcz2 commented 3 months ago

Hello, could you please copy and paste the exact error output?

ahmademami97 commented 3 months ago

sure here it is:

ERROR Command ['python', '-m', 'tile2net', 'inference', '--city_info', '/content/output/test_tile/tiles/test_tile_256_info.json', '--interactive', '--dump_percent', '0'] returned non-zero exit status 1. Stdout: Stderr: INFO NumExpr defaulting to 2 threads. INFO Inferencing. Segmentation results will not be saved. INFO Downloading weights for segmentation, this may take a while... INFO Weights downloaded. INFO Using a single GPU. INFO Using Per Image based weighted loss INFO Using Cross Entropy Loss INFO Loading weights from: checkpoint=/content/tile2net/src/tile2net/raster/resources/assets/weights/satellite_2021.pth INFO init weights from normal distribution INFO loading pretrained model /content/tile2net/src/tile2net/raster/resources/assets/weights/hrnetv2_w48_imagenet_pretrained.pth INFO Trunk: hrnetv2 INFO Model params = 72.1M /usr/lib/python3.10/multiprocessing/popen_fork.py:66: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock. self.pid = os.fork() INFO Polygons are generated and saved! INFO Starting network creation...

0%| | 0/1 [00:00<?, ?it/s] 100%|██████████| 1/1 [00:00<00:00, 2828.26it/s]

0%| | 0/1 [00:00<?, ?it/s] 100%|██████████| 1/1 [00:00<00:00, 2686.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 375, in convert_whole_poly2line self.create_sidewalks() File "/content/tile2net/src/tile2net/raster/pednet.py", line 344, in create_sidewalks swntw.geometry = swntw.simplify(0.6) AttributeError: 'NoneType' object has no attribute 'simplify'


CalledProcessError Traceback (most recent call last) in <cell line: 1>() ----> 1 raster1.inference()

2 frames /usr/lib/python3.10/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs) 524 retcode = process.poll() 525 if check and retcode: --> 526 raise CalledProcessError(retcode, process.args, 527 output=stdout, stderr=stderr) 528 return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command '['python', '-m', 'tile2net', 'inference', '--city_info', '/content/output/test_tile/tiles/test_tile_256_info.json', '--interactive', '--dump_percent', '0']' returned non-zero exit status 1.

dhodcz2 commented 3 months ago

Could you please also pass the command that you ran?

ahmademami97 commented 3 months ago

raster1 = Raster( location=[-33.72176969693144, 150.72435381126422,-33.71948521547603, 150.7271003932958], name='test_tile', input_dir='/content/test_tile/x_y.png', output_dir='/content/output', zoom=21, crs=3857

) raster1.generate(2) raster1.inference()

dhodcz2 commented 3 months ago

Thank you for using Tile2net. The CRS parameter is intended to be paired with the location parameter, not the geometry which encapsulates its CRS in its metadata. Please leave the CRS to be the default 4326 coordinate system (WGS84). As for the slightly misaligned results, could you please overlay it onto the source imagery by opening a new session where you make sure the base coordinate is 4326?

Mary-h86 commented 3 months ago

@ahmademami97 A side note here: Tile2Net works with Slippy Tiles Map system (XYZ system) (read our data preparation guide here). This requires tiles to be in EPSG: 4326, you can use QGIS to re-project your large raster to 4326 and then tile it again according to XYZ to arrive at the most accurate results.

ahmademami97 commented 3 months ago

Thank you so much, @Mary-h86 and @dhodcz2, for your notes and help. I fixed the misalignment in my network. There was a small issue with the conversion to the slippy tile system in my code. It's all working fine now.

Mary-h86 commented 3 months ago

Perfect! Happy to hear that. I am closing this issue now. Feel free to re-open if you have any other questions.