Skip to content

Commit

Permalink
fix readme and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
biplovbhandari committed Apr 16, 2024
1 parent bcf6a44 commit 5527cf8
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 681 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from aces.model_trainer import ModelTrainer

if __name__ == "__main__":
config_file = "config.env"
config = Config()
config = Config(config_file)
trainer = ModelTrainer(config)
trainer.train_model()
```
Expand Down
6 changes: 6 additions & 0 deletions aces/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ class Config:
"""

def __init__(self, config_file, override=False) -> None:
"""
ACES Configuration Class Constructor
Args:
config_file (str): The path to the configuration file.
override (bool): Flag to override the configuration settings.
"""
load_dotenv(config_file, override=override)

self.BASEDIR = Path(os.getenv("BASEDIR"))
Expand Down
4 changes: 4 additions & 0 deletions aces/ee_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ def get_credentials_by_service_account_key(key):
def initialize_session(use_highvolume : bool = False, key : Union[str, None] = None, project: str = None):
"""
Initialize the Earth Engine session.
If use_highvolume is True, the high-volume Earth Engine API will be used.
If a project is provided, the session will be initialized with the project ID. Recommended to use project.
If a key is provided, the service account key will be used.
Parameters:
use_highvolume (bool): Whether to use the high-volume Earth Engine API.
key (str or None): The path to the service account key JSON file. If None, the default credentials will be used.
project (str): The Google Cloud project ID to use for the session.
"""
if key is None:
if use_highvolume and project:
Expand Down
6 changes: 4 additions & 2 deletions aces/model_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,15 @@ def save_plots(self) -> None:
Saves the model architecture plot, training history plot, and model object.
"""
print(f"Saving plots and model visualization at {self.config.MODEL_SAVE_DIR}...")

Utils.plot_metrics([key.replace("val_", "") for key in self.history.history.keys() if key.startswith("val_")],
self.history.history, len(self.history.epoch), self.config.MODEL_SAVE_DIR)

if self.config.USE_AI_PLATFORM:
keras.utils.plot_model(self._model, f"{self.config.MODEL_SAVE_DIR}/model.png", show_shapes=True, rankdir="TB")
keras.utils.plot_model(self.model, f"{self.config.MODEL_SAVE_DIR}/wrapped_model.png", show_shapes=True, rankdir="LR") # rankdir='TB'
else:
keras.utils.plot_model(self.model, f"{self.config.MODEL_SAVE_DIR}/model.png", show_shapes=True, rankdir="TB") # rankdir='TB'
Utils.plot_metrics([key.replace("val_", "") for key in self.history.history.keys() if key.startswith("val_")],
self.history.history, len(self.history.epoch), self.config.MODEL_SAVE_DIR)

def save_history_object(self) -> None:
"""
Expand Down
278 changes: 75 additions & 203 deletions notebook/aces_rice_classification_paro_2021.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions notebook/count_sample_size.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"source": [
"# Rice mapping in Bhutan with U-Net using high resolution satellite imagery\n",
"\n",
"### This notebook shows an example of counting the sample size from the `tfrecords`\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/SERVIR/servir-aces/blob/main/notebooks/count_sample_size.ipynb\">\n",
Expand All @@ -45,9 +47,7 @@
"</table>\n",
"</br>\n",
"</br>\n",
"</br>\n",
"\n",
"### This notebook shows an example of counting the sample size from the `tfrecords`"
"</br>"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions notebook/prediction_dnn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"source": [
"# Rice mapping in Bhutan with U-Net using high resolution satellite imagery\n",
"\n",
"### This notebook shows an example of using the TFRecord images for prediction using saved DNN Model.\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/SERVIR/servir-aces/blob/main/notebooks/prediction_dnn.ipynb\">\n",
Expand All @@ -45,9 +47,7 @@
"</table>\n",
"</br>\n",
"</br>\n",
"</br>\n",
"\n",
"### This notebook shows an example of using the TFRecord images for prediction using saved DNN Model."
"</br>"
]
},
{
Expand Down
Loading

0 comments on commit 5527cf8

Please sign in to comment.