Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
acerioni committed Jan 25, 2021
2 parents 8296bf4 + a7d7402 commit 50d1a51
Show file tree
Hide file tree
Showing 22 changed files with 2,536 additions and 20 deletions.
2 changes: 1 addition & 1 deletion config_NE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ assess_predictions_NE.py:
trn: output-NE/trn_predictions_at_0dot05_threshold.pkl
val: output-NE/val_predictions_at_0dot05_threshold.pkl
tst: output-NE/tst_predictions_at_0dot05_threshold.pkl
#all: output-NE/all_predictions_at_0dot05_threshold.pkl
all: output-NE/all_predictions_at_0dot05_threshold.pkl
folders:
output: output-NE

42 changes: 42 additions & 0 deletions config_NEuGE.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
generate_training_sets_NE.py:
datasets:
ground_truth_sectors_shapefile: data-update/Sectors_groundtruth.shp
other_sectors_shapefile: data-update/Sectors_other.shp
ground_truth_swimming_pools_shapefile: data-update/sp_gt_missing_manuell.shp
other_swimming_pools_shapefile: data-update/Swimmingpools_other.shp
orthophotos_web_map_service:
url: https://sitn.ne.ch/mapproxy95/service
layers: ortho2019
srs: "EPSG:900913"
folders:
output: output-comb
tile_size: 256 # per side, in pixels
save_image_metadata: True
overwrite: False
n_jobs: 100
COCO_metadata:
year: 2020
version: 1.0
description: 2019 orthophotos w/ Swimming Pool segmentations
contributor: Système d'information du territoire Neuchâtelois (SITN)
url: https://sitn.ne.ch
license:
name: Unknown
url:


assess_predictions_NE.py:
n_jobs: 100
datasets:
labels_geojson: output-comb/labels-NE-manuell-fuse.geojson
image_metadata_json: output-comb/img_metadata.json
OK_tiles_geojson: output-comb/OK_tiles.geojson # tiles including at least one swimming pool, split in trn/val/tst subsets
aoi_tiles_geojson: output-comb/aoi_z18_tiles.geojson # aoi = Area of Interest
predictions:
trn: output-comb/trn_predictions_at_0dot05_threshold.pkl
val: output-comb/val_predictions_at_0dot05_threshold.pkl
tst: output-comb/tst_predictions_at_0dot05_threshold.pkl
all: output-comb/all_predictions_at_0dot05_threshold.pkl
folders:
output: output-comb/assessment-GEuNE

182 changes: 182 additions & 0 deletions data-update/OK_tiles.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data-update/Swimmimgpools_groundtruth_missing.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file added data-update/Swimmimgpools_groundtruth_missing.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions data-update/Swimmimgpools_groundtruth_missing.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["CH1903+_LV95",GEOGCS["GCS_CH1903+",DATUM["D_CH1903+",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["latitude_of_center",46.95240555555556],PARAMETER["longitude_of_center",7.439583333333333],PARAMETER["azimuth",90],PARAMETER["scale_factor",1],PARAMETER["false_easting",2600000],PARAMETER["false_northing",1200000],UNIT["Meter",1]]
1 change: 1 addition & 0 deletions data-update/Swimmimgpools_groundtruth_missing.qpj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["CH1903+ / LV95",GEOGCS["CH1903+",DATUM["CH1903+",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[674.374,15.056,405.346,0,0,0,0],AUTHORITY["EPSG","6150"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4150"]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["latitude_of_center",46.95240555555556],PARAMETER["longitude_of_center",7.439583333333333],PARAMETER["azimuth",90],PARAMETER["rectified_grid_angle",90],PARAMETER["scale_factor",1],PARAMETER["false_easting",2600000],PARAMETER["false_northing",1200000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","2056"]]
Binary file added data-update/Swimmimgpools_groundtruth_missing.shp
Binary file not shown.
Binary file added data-update/Swimmimgpools_groundtruth_missing.shx
Binary file not shown.
Binary file added data-update/Swimmingpools_groundtruth_modifie.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions data-update/Swimmingpools_groundtruth_modifie.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["CH1903+_LV95",GEOGCS["GCS_CH1903+",DATUM["D_CH1903+",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["False_Easting",2600000.0],PARAMETER["False_Northing",1200000.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Azimuth",90.0],PARAMETER["Longitude_Of_Center",7.439583333333333],PARAMETER["Latitude_Of_Center",46.95240555555556],UNIT["Meter",1.0],AUTHORITY["EPSG",2056]]
Binary file added data-update/Swimmingpools_groundtruth_modifie.shp
Binary file not shown.
Binary file added data-update/Swimmingpools_groundtruth_modifie.shx
Binary file not shown.
1 change: 1 addition & 0 deletions data-update/aoi_z18_tiles.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data-update/img_metadata.json

Large diffs are not rendered by default.

1,080 changes: 1,080 additions & 0 deletions data-update/labels-NE-manuell-fuse.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions data-update/sp_gt_missing_manuell.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
6 changes: 3 additions & 3 deletions helpers/MIL.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ def get_geotiff(mil_url, bbox, width, height, filename, imageSR=2056, bboxSR=205

#print('Fetching image...')
url = image_metadata['href']
r = requests.get(url, allow_redirects=True, verify=False)
#print(f'Writing image file: {tiff_filename}')
r = requests.get(url, allow_redirects=True, verify=False, timeout=10)
print(f'Writing image file: {tiff_filename}')
with open(tiff_filename, 'wb') as fp:
fp.write(r.content)

#print(f'TIFF -> GeoTIFF: {geotiff_filename}')
print(f'TIFF -> GeoTIFF: {geotiff_filename}')
src_ds = gdal.Open(tiff_filename)
#dst_ds = gdal.Translate(geotiff_filename, src_ds, options='-of GTiff -a_srs EPSG:2056 -a_nodata 253')
gdal.Translate(geotiff_filename, src_ds, options=f'-of GTiff -a_srs EPSG:{imageSR}')
Expand Down
12 changes: 7 additions & 5 deletions helpers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import pandas as pd
import geopandas as gpd
import numpy as np

from shapely.affinity import affine_transform, scale
from shapely.geometry import box
Expand Down Expand Up @@ -75,16 +76,17 @@ def fast_predictions_to_features(predictions_dict, img_metadata_dict):

kk = k.split('/')[-1]
this_img_metadata = img_metadata_dict[kk]

#print(this_img_metadata)

crs = f"EPSG:{this_img_metadata['extent']['spatialReference']['latestWkid']}"
transform = image_metadata_to_affine_transform(this_img_metadata)

#print(transform)
for pred in v:

#print(pred)
if 'pred_mask' in pred.keys():

pred_mask_int = pred['pred_mask'].astype(int)

pred_mask_int = pred['pred_mask'].astype(np.uint8)
#print(pred_mask_int)
feats += [{'type': 'Feature',
'properties': {'raster_val': v, 'score': pred['score'], 'crs': crs},
'geometry': s
Expand Down
Loading

0 comments on commit 50d1a51

Please sign in to comment.