From 7a542671c97a0d3c2163c28ca7725952076c08af Mon Sep 17 00:00:00 2001 From: kyle-woodward Date: Tue, 9 Jul 2024 14:06:32 -0400 Subject: [PATCH] housekeeping before ownership txfer --- fao_models/beam_pipelines/test_pyshp.py | 7 ------- fao_models/beam_utils.py | 4 ++-- fao_models/model_predict.py | 6 +++--- 3 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 fao_models/beam_pipelines/test_pyshp.py diff --git a/fao_models/beam_pipelines/test_pyshp.py b/fao_models/beam_pipelines/test_pyshp.py deleted file mode 100644 index 0d3bc79..0000000 --- a/fao_models/beam_pipelines/test_pyshp.py +++ /dev/null @@ -1,7 +0,0 @@ -# works but i don't think we'll be able ot make centroid lat lon with this package easily -import shapefile - -input_file = 'C:\\Users\\kyle\\Downloads\\ALL_centroids_completed_v1_\\ALL_centroids_completed_v1_.shp' -sf = shapefile.Reader(input_file) -print(sf.fields) -print(sf.records()[0:10]) \ No newline at end of file diff --git a/fao_models/beam_utils.py b/fao_models/beam_utils.py index af041dc..c52af27 100644 --- a/fao_models/beam_utils.py +++ b/fao_models/beam_utils.py @@ -6,11 +6,11 @@ import numpy as np from models import get_model, freeze -def parse_shp_to_latlon(file): +def parse_shp_to_latlon(file,id_field:str='PLOTID'): gdf = gpd.read_file(file) gdf.loc[:,'centroid'] = gdf.geometry.centroid gdf.loc[:,'lonlat'] = gdf.centroid.apply(lambda x: [x.x, x.y]) - return gdf[['global_id', 'lonlat']].values.tolist() + return gdf[[id_field, 'lonlat']].values.tolist() def get_ee_img(coords): """retrieve s2 image composite from ee at given coordinates. coords is a tuple of (lon, lat) in degrees.""" diff --git a/fao_models/model_predict.py b/fao_models/model_predict.py index 3d3e77e..bf005fe 100644 --- a/fao_models/model_predict.py +++ b/fao_models/model_predict.py @@ -1,7 +1,7 @@ import numpy as np import datetime import logging -from .models import get_model +from models import get_model import os import tensorflow as tf import rasterio as rio @@ -63,11 +63,11 @@ def main(config: str | dict): loss_function = config["loss_function"] model = load_predict_model(model_name, optimizer, loss_function, weights) - + print(model.summary()) # load image # local file as placeholder # img = "data/patch_pt9097_nonforest.tif" - img = "data_qa_old_caf\patch_pt0_nonforest.tif" + img = "data\\data_qa_old_caf\\patch_pt0_nonforest.tif" with rio.open(img) as dst: data = dst.read() / 10_000 profile = dst.profile