PatBall1 / detectree2

Python package for automatic tree crown delineation based on the Detectron2 implementation of Mask R-CNN
https://patball1.github.io/detectree2/
MIT License
148 stars 35 forks source link

Tiled data not saved to directory #142

Open yby026 opened 2 months ago

yby026 commented 2 months ago

Hi there, when I tried to adjust my settings in tilling for training my dataset using codes below, the tile_data_train didn't save the tiled data into my target folder. The codes correctly created the folders, but none of the tiled result appears in the folders.

buffer = 10
tile_width = 14
tile_height = 16
threshold = 0.7
appends = "width_buffer_" + str(tile_width) + "_" + str(buffer) + "_" + str(threshold) + "_train" 
tile_dir = tiles_path + appends + "/"
tile_data_train(data, tile_dir, buffer, tile_width, tile_height, crowns, threshold=0.7, nan_threshold=0.99)
to_traintest_folders(tile_dir, tile_dir, test_frac=0, strict=True, folds=4)

I'm running it on Google colab, the problem is not always happening (works fine in most cases), but this time it happened when I simply changed tile_width and tile_height for the same dataset, changing dtype_bool=True or remove nan_threshold are not working neither. Not sure where is this bug coming from.

There's no error message, and the output is like this:

/usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] /usr/local/lib/python3.10/dist-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information. return [json.loads(gdf.to_json())["features"][0]["geometry"]] Tiling complete

PatBall1 commented 2 months ago

@yby026 what CRS are your crowns and geotiffs in? It appears to be related to that.

We recommend using the UTM CRS suitable for your region. You can reproject with to_crs with geopandas and reproject in rasterio.

yby026 commented 2 months ago

@PatBall1 they are all in NZGD2000 (EPSG2193), I've tried to reproject it into EPSG2134 (NZGD 2000 UTM Zone 59S), the problem still preserves.

PatBall1 commented 2 months ago

@yby026 have you tried reducing the threshold (e.g. to theshold = 0)?

If you are still having problems, I can have a look at your data. Not that it should affect things, but you are using quite small tiles that are not square,

yby026 commented 2 months ago

Thanks! reduced threshold to 0.3 solved the problem!

Jonetz commented 1 week ago

Hello,

I somehow have exactly the same issue at hand, i get this warning message, when calling tile_data_train:

/home/…/miniconda3/envs/myenv/lib/python3.10/site-packages/detectree2/preprocessing/tiling.py:47: UserWarning: GeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information.

I used the following tiling Parameters: tile_width = tile_height = 150 (also tried 50) buffer = 20 threshold = 0.0 (also tried 0.1 and 0.3)

I am working on 1km x 1km tiles with EPSG:25832, but also tried using the cambridge data from the urban model, all modifications did not change anything. The logging shows no other warnings besides the one mentioned above.

This is my error trace:

/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Loading and preparing results... Traceback (most recent call last): File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectree2/models/train.py", line 210, in train self.after_step() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/engine/train_loop.py", line 190, in after_step h.after_step() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/engine/hooks.py", line 556, in after_step self._do_eval() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/engine/hooks.py", line 529, in _do_eval results = self._func() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/engine/defaults.py", line 457, in test_and_save_results self._last_eval_results = self.test(self.cfg, self.model) File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/engine/defaults.py", line 621, in test results_i = inference_on_dataset(model, data_loader, evaluator) File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/evaluation/evaluator.py", line 213, in inference_on_dataset results = evaluator.evaluate() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/evaluation/coco_evaluation.py", line 206, in evaluate self._eval_predictions(predictions, img_ids=img_ids) File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/evaluation/coco_evaluation.py", line 266, in _eval_predictions _evaluate_predictions_on_coco( File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/evaluation/coco_evaluation.py", line 590, in _evaluate_predictions_on_coco coco_dt = coco_gt.loadRes(coco_results) File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/pycocotools/coco.py", line 327, in loadRes assert set(annsImgIds) == (set(annsImgIds) & set(self.getImgIds())), \ AssertionError: Results do not correspond to current coco set

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/hkfs/home/project/.../tree_detection_lgl/detectree/training_test.py", line 130, in main(args) File "/hkfs/home/project/.../tree_detection_lgl/detectree/training_test.py", line 116, in main train_model(params) File "/hkfs/home/project/.../tree_detection_lgl/detectree/training_test.py", line 106, in train_model trainer.train() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectree2/models/train.py", line 221, in train self.after_train() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectron2/engine/train_loop.py", line 174, in after_train h.after_train() File "/home/.../miniconda3/envs/myenv/lib/python3.10/site-packages/detectree2/models/train.py", line 159, in after_train index = self.trainer.APs.index(max(self.trainer.APs)) + 1 ValueError: max() arg is an empty sequence

Do you have any advice regarding this issue, that could point me towards a solution?

Best Regards, Jonas

PatBall1 commented 1 week ago

Hi @Jonetz , thanks for raising this.

Would you please share the sequence of code you ran? The original warning against the CRS of the geopandas dataframe may be the source of the problem. You may want to project into a compatible CRS.

Jonetz commented 1 week ago

Hello James,

as an update, I was able to eliminate the CRS warning, changing the structure of the geopandas dataframe a bit, but this did not mitigate the original problem. This is my source code:

from detectree2.preprocessing.tiling import tile_data_train, to_traintest_folders
from detectree2.models.train import register_train_data, setup_cfg, MyTrainer
import rasterio
import geopandas as gpd
from glob import glob
import os
import logging
import argparse
import json

def setup_logging(params):
    logger = logging.getLogger(__name__)
    logging.basicConfig(filename=os.path.join(params['site_path'], 'logs.log'), format='%(asctime)s %(message)s', encoding='utf-8', level=logging.DEBUG)
    return logger

def get_params(args):
    return {
        'site_path': args.site_path,
        'image_path': os.path.join(args.site_path, 'rgb'),
        'mask_path': os.path.join(args.site_path, 'masks'),
        'json_path': os.path.join(args.site_path, 'crowns'),
        'tile_path': os.path.join(args.site_path, 'tiles'),
        'buffer': args.buffer, 
        'tile_width': args.tile_width,
        'tile_height': args.tile_height,
        #'box_threshold': args.box_threshold,
        #'iou_threshold': args.iou_threshold,
        'test_frac': 0.15,
        'val_fold': args.val,
        'threshold': 0.0

    }

def preprocess_data(params, logger):

    for rgb_file in glob(os.path.join(params['image_path'], '*.tif')):
        filename_withending = os.path.basename(rgb_file)
        filename = os.path.splitext(filename_withending)[0]

        json_file = os.path.join(params['json_path'], filename + '.json')

        if not os.path.exists(json_file):
            print(f'Could not find file {json_file}, skipping this one.')
            logger.debug(f'Could not find file {json_file}, skipping this one.')
            continue

        # Read in the tiff file
        data = rasterio.open(rgb_file)

        # Read in crowns (then filter by an attribute if required)
        crowns = gpd.read_file(json_file)

        tile_data_train(data, params['tile_path'], params['buffer'], params['tile_width'], params['tile_height'], crowns, params['threshold'])

        if params['val_fold'] is not None and params['val_fold'] > 0:
          to_traintest_folders(params['tile_path'], params['tile_path'], test_frac=params['test_frac'], strict=True, folds=params['val_fold'])
        else:
          to_traintest_folders(params['tile_path'], params['tile_path'], test_frac=params['test_frac'], strict=True)

def train_model(params):
    out_path = os.path.join(params['tile_path'], "train")
    register_train_data(out_path, 'BW', params['val_fold'])

    # Set the base (pre-trained) model from the detectron2 model_zoo
    base_model = "COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml"

    trains = ("BW_train",)  # Registered train data
    tests = ("BW_val",)  # Registered validation data

    out_dir = os.path.join(params['site_path'], "train_output")
    if not os.path.exists(out_dir):
        os.makedirs(out_dir)

    cfg = setup_cfg(base_model, trains, tests, workers=4, eval_period=100, max_iter=3000, out_dir=out_dir)  # update_model arg can be used to load in trained model

    trainer = MyTrainer(cfg, patience=5)
    trainer.resume_or_load(resume=False)
    trainer.train()

def main(args):
    print('Starting Main')
    params = get_params(args)
    print('Loaded Params')
    logger = setup_logging(params)
    print('Setup Logging')
    preprocess_data(params, logger)
    print('Preprocessed data')
    train_model(params)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Tree Detection Training Script")
    parser.add_argument("--site_path", type=str, required=True, help="Path to the site directory")
    parser.add_argument("--buffer", type=int, default=20, help="Buffer size for tiling")
    parser.add_argument("--tile_width", type=int, default=150, help="Width of the tile")
    parser.add_argument("--tile_height", type=int, default=150, help="Height of the tile")
    #parser.add_argument("--box_threshold", type=float, default=0.5, help="Box threshold")
    #parser.add_argument("--iou_threshold", type=float, default=0.4, help="IoU threshold")
    parser.add_argument("--val", type=int, default=5, help="Validation Fold Count")
    parser.add_argument("--threshold", type=float, default=0.0, help="Threshold for tiling")

    args = parser.parse_args()
    main(args)

I use the following modules:

PatBall1 commented 1 week ago

@Jonetz, thanks for sharing the code. The problem is not immediately obvious to me but you should try:

In tile_data_train, set test_frac=0 or strict=True

If you are happy to do so, you can share your data with me (ball.jgc@gmail.com) and I'll have a little look.