avanetten / simrdwn

Rapid satellite imagery object detection
216 stars 154 forks source link

Error while executing geomPixel2geomGeo in /simrdwn/simrdwn/core/add_geo_coords.py #61

Closed jacquesmats closed 5 years ago

jacquesmats commented 5 years ago

Hey @avanetten, sorry to bother you again, but I'm almost getting the tutorial on COWC running!

I shifted to the Yolt2 framework. While running the test command:

python /simrdwn/simrdwn/core/simrdwn.py \
    --framework yolt2 \
    --mode test \
    --outname dense_cowc \
    --label_map_path /simrdwn/data/train_data/class_labels_car.pbtxt \
    --train_model_path /simrdwn/results/train_yolt2_dense_cars_matheus_2019_07_15_14-15-39/ \
    --weight_file ave_dense_final.weights \
    --yolt_cfg_file ave_dense.cfg \
    --testims_dir /simrdwn/data/test_images/cowc/Utah_AGRC  \
    --keep_test_slices 0 \
    --test_slice_sep __ \
    --test_make_legend_and_title 0 \
    --edge_buffer_test 1 \
    --test_box_rescale_frac 1 \
    --plot_thresh_str 0.2 \
    --slice_sizes_str 416 \
    --slice_overlap 0.2 \
    --alpha_scaling 1 \
    --show_labels 1

I'm receiving the following error:

Traceback (most recent call last):
  File "/simrdwn/simrdwn/core/simrdwn.py", line 1936, in <module>
    main()
  File "/simrdwn/simrdwn/core/simrdwn.py", line 1928, in main
    execute(args, train_cmd1, test_cmd_tot, test_cmd_tot2)
  File "/simrdwn/simrdwn/core/simrdwn.py", line 1540, in execute
    test_add_geo_coords=args.test_add_geo_coords)
  File "/simrdwn/simrdwn/core/simrdwn.py", line 1130, in run_test
    outProj_str='epsg:3857', verbose=verbose)
  File "/simrdwn/simrdwn/core/add_geo_coords.py", line 217, in add_geo_coords_to_df
    inProj_str=inProj_str, outProj_str=outProj_str,
  File "/simrdwn/simrdwn/core/add_geo_coords.py", line 127, in get_row_geo_coords
    gdal_geomTransform=gdal_geomTransform)
  File "/simrdwn/simrdwn/core/add_geo_coords.py", line 70, in geomPixel2geomGeo
    [affineObject.a,
AttributeError: 'list' object has no attribute 'a'

It refers to this part of the code:

    geomTransform = shapely.affinity.affine_transform(shapely_geom,
                                                      [affineObject.a,
                                                       affineObject.b,
                                                       affineObject.d,
                                                       affineObject.e,
                                                       affineObject.xoff,
                                                       affineObject.yoff]
                                                      )

I never worked with geospatial data, so all these libs are new to me. Seems you were expecting an object and receive a list instead. I try to change this to:


    geomTransform = shapely.affinity.affine_transform(shapely_geom,
                                                      [affineObject[0],
                                                       affineObject[1],
                                                       affineObject[2],
                                                       affineObject[3],
                                                       affineObject[4],
                                                       affineObject[5]]
                                                      )

But it trows more errors.

It may be related to https://github.com/mapbox/rasterio/issues/86.

Since this command is used a little early at function _add_geo_coords_todf:

# raster geo transform
        gdal_geomTransform = gdal.Open(raster_loc).GetGeoTransform()
        affineObject = rio.open(raster_loc).transform

I'll keep trying to solve it, but if it is trivial for you, please let me know!

avanetten commented 5 years ago

The most recent version should solve this issue.

Fred-Macdo commented 5 years ago

Thank you, I have been stuck on this error for a few days.