diff --git a/.gitignore b/.gitignore index c2eade0..60a0348 100644 --- a/.gitignore +++ b/.gitignore @@ -145,4 +145,7 @@ _build/ dataset # Model Artifacts (HDF5) -*.h5 \ No newline at end of file +*.h5 + +# TensorBoard +logs/ \ No newline at end of file diff --git a/README.md b/README.md index d85f3a1..af13ac6 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,10 @@ from covid_xray_classification.models.xception import Small from covid_xray_classification.data import Downloader, Reshaper from pandas import read_csv from os.path import join -from tensorflow.keras.callbacks import EarlyStopping +from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint, TensorBoard from tensorflow.keras.optimizers import Adam from tensorflow.keras.preprocessing import image_dataset_from_directory from tensorflow.keras.metrics import BinaryAccuracy,Precision,Recall -from keras.callbacks import ModelCheckpoint # Download default dataset to default location @@ -75,7 +74,10 @@ callbacks = [EarlyStopping("loss", mode='min', restore_best_weights=True), # Save the model at the end of each epoch. - ModelCheckpoint("epoch_{epoch}.h5")] + ModelCheckpoint("epoch_{epoch}.h5"), + # Log data to directory logs for TensorBoard + TensorBoard( + log_dir="logs")] # Specify the metrics we wish to evaluate at the end of each epoch. metrics = ["accuracy", @@ -127,6 +129,7 @@ model.fit( callbacks=callbacks, validation_data=val_ds) +# Save our model for later use. model.save(join('dataset', f"{model_name}.h5")) ``` \ No newline at end of file diff --git a/example.py b/example.py index c313542..aabaf50 100644 --- a/example.py +++ b/example.py @@ -3,11 +3,10 @@ from covid_xray_classification.data import Downloader, Reshaper from pandas import read_csv from os.path import join -from tensorflow.keras.callbacks import EarlyStopping +from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint, TensorBoard from tensorflow.keras.optimizers import Adam from tensorflow.keras.preprocessing import image_dataset_from_directory from tensorflow.keras.metrics import BinaryAccuracy,Precision,Recall -from keras.callbacks import ModelCheckpoint # Download default dataset to default location @@ -59,7 +58,10 @@ mode='min', restore_best_weights=True), # Save the model at the end of each epoch. - ModelCheckpoint("epoch_{epoch}.h5")] + ModelCheckpoint("epoch_{epoch}.h5"), + # Log data to directory logs for TensorBoard + TensorBoard( + log_dir="logs")] # Specify the metrics we wish to evaluate at the end of each epoch. metrics = ["accuracy",