From e5bb98f65493f967b86a87407422b63397c0cfbf Mon Sep 17 00:00:00 2001 From: Sai Ma Date: Thu, 19 Dec 2024 02:33:27 +0000 Subject: [PATCH] Fix the information on FMC cfg --- .../fmc_processings/ga_s2ab_nbart_dea_fmc.yaml | 2 +- scripts/fmc_processing_script.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configs/fmc_processings/ga_s2ab_nbart_dea_fmc.yaml b/configs/fmc_processings/ga_s2ab_nbart_dea_fmc.yaml index beb7742..66c22b1 100644 --- a/configs/fmc_processings/ga_s2ab_nbart_dea_fmc.yaml +++ b/configs/fmc_processings/ga_s2ab_nbart_dea_fmc.yaml @@ -58,4 +58,4 @@ product: - landsat:wrs_row - fmask:clear -model_path: https://dea-public-data-dev.s3.ap-southeast-2.amazonaws.com/projects/burn_cube/configs/RF_model_ARDC_version.joblib +model_path: https://dea-public-data-dev.s3.ap-southeast-2.amazonaws.com/projects/burn_cube/configs/RF_AllBands_noLC_DEA_labeless.joblib diff --git a/scripts/fmc_processing_script.py b/scripts/fmc_processing_script.py index 5730fda..b72ce0d 100644 --- a/scripts/fmc_processing_script.py +++ b/scripts/fmc_processing_script.py @@ -84,6 +84,16 @@ def classify_FMC(data, model): return dataset_result +def download_file_from_s3_public(url, file_path): + response = requests.get(url) + if response.status_code == 200: + with open(file_path, "wb") as f: + f.write(response.content) + print(f"File downloaded successfully from: {url}") + else: + print(f"Failed to download file from: {url}") + + @click.command(no_args_is_help=True) @click.option( "--task-id", @@ -131,6 +141,13 @@ def fmc_processing( dc = datacube.Datacube(app="fmc_processing") + # Define the path to the saved machine learning model file. + model_path = "RF_AllBands_noLC_DEA_labeless.joblib" + + # auto download Machine Learning model from AWS S3 + + download_file_from_s3_public(model_url, model_path) + # import model: move it to fmc processing cfg file model = joblib.load(model_url)