cosmiq / apls Goto Github PK
View Code? Open in Web Editor NEWPython code to evaluate the APLS metric
License: Apache License 2.0
Python code to evaluate the APLS metric
License: Apache License 2.0
Please help on this issue.
Gathering files...
Creating networkx graph from downloaded OSM data...
Added edge lengths to graph in 0.01 seconds
Created graph with 94 nodes and 230 edges in 0.28 seconds
Begin topologically simplifying the graph...
Identified 71 edge endpoints in 0.00 seconds
Constructed all paths to simplify in 0.00 seconds
Simplified graph (from 94 to 71 nodes and from 230 to 184 edges) in 0.01 seconds
Retrieve proposal graph...
Running wkt_list_to_nodes_edges()...
Time to run wkt_list_to_nodes_egdes(): 0.014730691909790039 seconds
Creating G...
len(G.nodes(): 142
len(G.edges(): 166
Time to run nodes_edges_to_G(): 0.011862039566040039 seconds
Clean out short subgraphs
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-24-3a2f4f5cb49d> in <module>
3 prop_dir='/Users/an.tran/Desktop/map-workspace/code/apls/apls/data/gt_json_prop_wkt/proposal',
4 im_dir='/Users/an.tran/Desktop/map-workspace/code/apls/apls/data/images',
----> 5 wkt_file='/Users/an.tran/Desktop/map-workspace/code/apls/apls/data/gt_json_prop_wkt/proposal/sn3_sample_submission_albu.csv')
/usr/local/lib/python3.7/site-packages/apls/apls.py in gather_files(test_method, truth_dir, prop_dir, im_dir, im_prefix, wkt_file, max_files, gt_subgraph_filter_weight, gt_min_subgraph_length, prop_subgraph_filter_weight, prop_min_subgraph_length, use_pix_coords, speed_key, travel_time_key, default_speed, verbose, super_verbose)
2305 node_iter=node_iter,
2306 edge_iter=edge_iter,
-> 2307 verbose=super_verbose)
2308
2309 t2 = time.time()
/usr/local/lib/python3.7/site-packages/apls/wkt_to_G.py in wkt_to_G(wkt_list, im_file, prop_subgraph_filter_weight, min_subgraph_length, node_iter, edge_iter, simplify_graph, verbose)
299
300 print("Clean out short subgraphs")
--> 301 G0 = apls._clean_sub_graphs(G0, min_length=min_subgraph_length,
302 weight=prop_subgraph_filter_weight,
303 max_nodes_to_skip=30,
AttributeError: module 'apls' has no attribute '_clean_sub_graphs'
Hi,
May I ask how could I construct graphs from the generated masks?
I am calculating apls metric for comparison of two geojson's and getting this error :
Traceback (most recent call last):
File "apls.py", line 3690, in <module>
main()
File "apls.py", line 3661, in main
super_verbose=super_verbose)
File "apls.py", line 2552, in gather_files
verbose=verbose)
File "apls.py", line 998, in _create_gt_graph
super_verbose=super_verbose)
File "apls.py", line 1227, in _refine_gt_graph
verbose=verbose, super_verbose=super_verbose)
File "apls.py", line 909, in _clean_sub_graphs
sub_graphs = list(nx.connected_component_subgraphs(G_))
File "C:\Users\xyz\Anaconda3\envs\apls_new\lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "C:\Users\xyz\Anaconda3\envs\apls_new\lib\site-packages\networkx\utils\decorators.py", line 80, in _not_implemented_for
raise nx.NetworkXNotImplemented(msg)
networkx.exception.NetworkXNotImplemented: not implemented for directed type
apls_utils.py
only have _get_road_buffer
function, after I rename it to get_road_buffer
, I can run this script to generate RGB image and mask, but the generated mask image is pure dark, which means there is no label information on it. Can anyone help me?
does anyone have this problem?
`['gdal_translate', '-ot', 'Byte', '-of', 'GTiff', '-co', '"PHOTOMETRIC=rgb"', '-scale_1', '149.0', '790.0', '0', '255', '-scale_2', '301.0', '1022.0', '0', '255', '-scale_3', '263.0', '712.0', '0', '255', '/data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/RGB-PanSharpen/RGB-PanSharpen_AOI_2_Vegas_img699.tif', '/data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/RGB-PanSharpen_8bit/RGB-PanSharpen_AOI_2_Vegas_img699.tif']
Input file size is 1300, 1300
Warning 6: driver GTiff does not support creation option "PHOTOMETRIC
0...10...20...30...40...50...60...70...80...90...100 - done.
1 / 10
im_name: RGB-PanSharpen_AOI_2_Vegas_img699.tif
name_root: AOI_2_Vegas_img699
im_file_out: /data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/RGB-PanSharpen_8bit/RGB-PanSharpen_AOI_2_Vegas_img699.tif
mask_file: /data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/masks_2m/AOI_2_Vegas_img699.png
output_plot_file: /data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/masks_2m_plots/AOI_2_Vegas_img699.png
label_file: /data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/geojson/spacenetroads/spacenetroads_AOI_2_Vegas_img699.geojson
label_file: /data/hucheng/SpaceNet_Roads_Sample/AOI_2_Vegas_Roads_Sample/geojson/spacenetroads/spacenetroads_AOI_2_Vegas_img699.geojson
IllegalArgumentException: Invalid buffer endCap style
Traceback (most recent call last):
File "create_spacenet_masks.py", line 184, in
main()
File "create_spacenet_masks.py", line 176, in main
overwrite_ims=bool(args.overwrite_ims))
File "create_spacenet_masks.py", line 127, in create_masks
verbose=False)
File "/home/hucheng/data-process/apls/apls/apls_utils.py", line 583, in _get_road_buffer
projectToUTM=True)
File "/home/hucheng/data-process/apls/apls/apls_utils.py", line 493, in create_buffer_geopandas
cap_style=buffer_cap_style)
File "/opt/anaconda3/envs/apls/lib/python3.6/site-packages/geopandas/base.py", line 578, in buffer
for geom in self.geometry],
File "/opt/anaconda3/envs/apls/lib/python3.6/site-packages/geopandas/base.py", line 578, in
for geom in self.geometry],
File "/opt/anaconda3/envs/apls/lib/python3.6/site-packages/shapely/geometry/base.py", line 593, in buffer
mitre_limit))
File "/opt/anaconda3/envs/apls/lib/python3.6/site-packages/shapely/geometry/base.py", line 76, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value`
Please relax the requirements gdal to some things like:
GDAL>=2.2.0
It will make the install GDAL easier!
For test_method == 'gt_json_prop_wkt'
The image name is wrong
RGB-PanSharpen_AOI_2_Vegas_img0.tif โ AOI_2_Vegas_img0.tif
An Argument name is wrong
--wkt_file โ --prop_wkt_file
Command:
python apls.py --test_method=gt_json_prop_wkt --output_name="gt_json_prop_wkt/output" --truth_dir="gt_json_prop_wkt/gt" --prop_wkt_file="$gt_json_prop_wkt/wkt/sn3_sample_submission_albu.csv" --im_dir="gt_json_prop_wkt/image"
I encounter #8 and walk around that part, then unearth a new error:
For test_method == 'gt_json_prop_pkl', we have to deal with "Naming convention" problem
Implement a check to see if node names overlap between ground truth and proposal graphs.
I run the create_masks.py to generate masks for paris images.
It went wrong when came to img377 as following error info.
It worked with previous few images only down when dealing with img377.
Any idea about that?
Thank you!
name_root: img377
output_raster: /media/lok/dataset/lok/data/spacenet/road/data/AOI_3_Paris_Roads_Train/masks_2m/mask_img377.png
output_plot_file: /media/lok/dataset/lok/data/spacenet/road/data/AOI_3_Paris_Roads_Train/masks_2m_plots/mask_img377.png
geojsonfilename = /media/lok/dataset/lok/data/spacenet/road/data/AOI_3_Paris_Roads_Train/geojson/spacenetroads/spacenetroads_AOI_3_Paris_img377.geojson
Traceback (most recent call last):
File "create_spacenet_masks.py", line 112, in
main()
File "create_spacenet_masks.py", line 107, in main
verbose=False)
File "/media/lok/dataset/lok/data/spacenet/road/apls/src/apls_tools.py", line 432, in get_road_buffer
projectToUTM=True)
File "/media/lok/dataset/lok/data/spacenet/road/apls/src/apls_tools.py", line 329, in create_buffer_geopandas
inGDF = gpd.read_file(geoJsonFileName)
File "/home/lok/anaconda2/envs/apls_environment/lib/python2.7/site-packages/geopandas/io/file.py", line 19, in read_file
with fiona.open(filename, **kwargs) as f:
File "/home/lok/anaconda2/envs/apls_environment/lib/python2.7/site-packages/fiona/init.py", line 165, in open
enabled_drivers=enabled_drivers)
File "/home/lok/anaconda2/envs/apls_environment/lib/python2.7/site-packages/fiona/collection.py", line 153, in init
self.session.start(self)
File "fiona/ogrext.pyx", line 405, in fiona.ogrext.Session.start
File "fiona/_err.pyx", line 185, in fiona._err.GDALErrCtxManager.exit
fiona._err.CPLE_OpenFailedError: Failed to read GeoJSON data
Line 483 in 4a78807
The script doesnt transform the geojson to UTM, as the given parameter of the CRS is its own input CRS (WGS84, EPSG:4326).
To fix this Issue, remove the inGDF.crs from create_buffer_geopandas in apls_utils.py and comment out lines 82 and 83 in osmnx_funcs.py:
if (gdf.crs is not None) and ('proj' in gdf.crs) and (gdf.crs['proj'] == 'utm'):
return gdf
I know this Issue should be formatted better, but it is Christmas today and i want to celebratee :)
Changing 'convert_to_8Bit' to 'convertTo8Bit'
Hi @avanetten, I have a question about the APLS metric. How to compute the APLS metric from the pixel-wise segmentation of the road? Thankin advance.
Hi,
When I run python apls.py
as in the README file, it will generate the following errors. Please fix.
I use networkx==2.2
library.
Traceback (most recent call last):
File "apls.py", line 1648, in <module>
main()
File "apls.py", line 1275, in main
verbose=verbose)
File "apls.py", line 722, in create_gt_graph
super_verbose=False)
File "apls.py", line 653, in clean_sub_graphs
for u,v in all_lengths.iteritems():
AttributeError: 'generator' object has no attribute 'iteritems'
Thanks.
I tried to use your code.
I installed everything that dependencies required.
Following your guide, I typed below words in terminal.
python apls.py --test_method=gt_json_prop_json --output_name=gt_json_prop_json
--truth_dir=data/gt_json_prop_json/AOI_2_Vegas_Train/spacenetroads
--prop_dir=data/gt_json_prop_json/AOI_2_Vegas_Train/osm
I also checked that there are geojson files in indicated directories.
But after executing, I got this error message,
This error occur in this line.
Why they trigger error like that? Why G_gt_init has none value?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.