diff --git a/README.md b/README.md index efb8434..5e44830 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Cam2BEV ## Installation -We suggest to setup a **Python 3.7** virtual environment (e.g. by using _virtualenv_ or _conda_). Inside the virtual environment, users can then use _pip_ to install all package dependencies. The most important packages are _TensorFlow 2.1_ and _OpenCV 4.2_ +We suggest to setup a **Python 3.8** virtual environment (e.g. by using _virtualenv_ or _conda_). Inside the virtual environment, users can then use _pip_ to install all package dependencies. The most important packages are _TensorFlow 2.7_ and _OpenCV 4.5_ ```bash pip install -r requirements.txt ``` diff --git a/model/train.py b/model/train.py index 73e7404..7047235 100755 --- a/model/train.py +++ b/model/train.py @@ -168,8 +168,10 @@ def parse_sample(input_files, label_file): # create callbacks to be called after each epoch +n_batches_train = len(files_train_label) // conf.batch_size +n_batches_valid = len(files_valid_label) tensorboard_cb = tf.keras.callbacks.TensorBoard(tensorboard_dir, update_freq="epoch", profile_batch=0) -checkpoint_cb = tf.keras.callbacks.ModelCheckpoint(os.path.join(checkpoint_dir, "e{epoch:03d}_weights.hdf5"), period=conf.save_interval, save_weights_only=True) +checkpoint_cb = tf.keras.callbacks.ModelCheckpoint(os.path.join(checkpoint_dir, "e{epoch:03d}_weights.hdf5"), save_freq=n_batches_train*conf.save_interval, save_weights_only=True) best_checkpoint_cb = tf.keras.callbacks.ModelCheckpoint(os.path.join(checkpoint_dir, "best_weights.hdf5"), save_best_only=True, monitor="val_mean_io_u_with_one_hot_labels", mode="max", save_weights_only=True) early_stopping_cb = tf.keras.callbacks.EarlyStopping(monitor="val_mean_io_u_with_one_hot_labels", mode="max", patience=conf.early_stopping_patience, verbose=1) callbacks = [tensorboard_cb, checkpoint_cb, best_checkpoint_cb, early_stopping_cb] @@ -177,8 +179,6 @@ def parse_sample(input_files, label_file): # start training print("Starting training...") -n_batches_train = len(files_train_label) // conf.batch_size -n_batches_valid = len(files_valid_label) model.fit(dataTrain, epochs=conf.epochs, steps_per_epoch=n_batches_train, validation_data=dataValid, validation_freq=1, validation_steps=n_batches_valid, diff --git a/model/utils.py b/model/utils.py index dcadc55..3ed8843 100644 --- a/model/utils.py +++ b/model/utils.py @@ -252,7 +252,7 @@ def wcce(y_true, y_pred): class MeanIoUWithOneHotLabels(tf.keras.metrics.MeanIoU): - def __call__(self, y_true, y_pred, sample_weight=None): + def update_state(self, y_true, y_pred, sample_weight=None): y_true = tf.argmax(y_true, axis=-1) y_pred = tf.argmax(y_pred, axis=-1) - return super().__call__(y_true, y_pred, sample_weight=sample_weight) + return super().update_state(y_true, y_pred, sample_weight) diff --git a/preprocessing/ipm/ipm.py b/preprocessing/ipm/ipm.py index 9991d9e..028f088 100755 --- a/preprocessing/ipm/ipm.py +++ b/preprocessing/ipm/ipm.py @@ -155,7 +155,7 @@ def __init__(self, config): # setup masks to later clip invalid parts from transformed images (inefficient, but constant runtime) masks = [] for config in cameraConfigs: - mask = np.zeros((outputRes[0], outputRes[1], 3), dtype=np.bool) + mask = np.zeros((outputRes[0], outputRes[1], 3), dtype=bool) for i in range(outputRes[1]): for j in range(outputRes[0]): theta = np.rad2deg(np.arctan2(-j + outputRes[0] / 2 - droneConfig["YCam"] * pxPerM[0], i - outputRes[1] / 2 + droneConfig["XCam"] * pxPerM[1])) diff --git a/requirements.txt b/requirements.txt index f5a5a24..d765299 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,51 +1,62 @@ -absl-py==0.9.0 -astor==0.8.1 -cachetools==4.0.0 -certifi==2019.11.28 -chardet==3.0.4 -ConfigArgParse==1.1 -cycler==0.10.0 -decorator==4.4.2 -gast==0.2.2 -google-auth==1.11.3 -google-auth-oauthlib==0.4.1 +ConfigArgParse==1.5.3 +matplotlib==3.5.0 +opencv-python==4.5.4.58 +pandas==1.3.4 +PyYAML==6.0 +scikit-image==0.18.3 +seaborn==0.11.2 +tensorflow==2.7.0 +tqdm==4.62.3 + +absl-py==1.0.0 +astunparse==1.6.3 +cachetools==4.2.4 +certifi==2021.10.8 +charset-normalizer==2.0.7 +cycler==0.11.0 +flatbuffers==2.0 +fonttools==4.28.1 +gast==0.4.0 +google-auth==2.3.3 +google-auth-oauthlib==0.4.6 google-pasta==0.2.0 -grpcio==1.27.2 -h5py==2.10.0 -idna==2.9 -imageio==2.8.0 -Keras-Applications==1.0.8 -Keras-Preprocessing==1.1.0 -kiwisolver==1.1.0 -Markdown==3.2.1 -matplotlib==3.2.0 -networkx==2.4 -numpy==1.18.1 -oauthlib==3.1.0 -opencv-python==4.2.0.32 -opt-einsum==3.2.0 -pandas==1.0.2 -Pillow==7.0.0 -protobuf==3.11.3 +grpcio==1.41.1 +h5py==3.5.0 +idna==3.3 +imageio==2.10.4 +keras==2.7.0 +Keras-Preprocessing==1.1.2 +kiwisolver==1.3.2 +libclang==12.0.0 +Markdown==3.3.4 +networkx==2.6.3 +numpy==1.21.4 +oauthlib==3.1.1 +opt-einsum==3.3.0 +packaging==21.2 +Pillow==8.4.0 +protobuf==3.19.1 pyasn1==0.4.8 pyasn1-modules==0.2.8 -pyparsing==2.4.6 -python-dateutil==2.8.1 -pytz==2019.3 -PyWavelets==1.1.1 -PyYAML==5.3 -requests==2.23.0 +pyparsing==3.0.6 +python-dateutil==2.8.2 +pytz==2021.3 +PyWavelets==1.2.0 +requests==2.26.0 requests-oauthlib==1.3.0 -rsa==4.0 -scikit-image==0.16.2 -scipy==1.4.1 -seaborn==0.10.0 -six==1.14.0 -tensorboard==2.1.1 -tensorflow==2.1.0 -tensorflow-estimator==2.1.0 +rsa==4.7.2 +scipy==1.7.2 +setuptools-scm==6.3.2 +six==1.16.0 +tensorboard==2.7.0 +tensorboard-data-server==0.6.1 +tensorboard-plugin-wit==1.8.0 +tensorflow-estimator==2.7.0 +tensorflow-io-gcs-filesystem==0.22.0 termcolor==1.1.0 -tqdm==4.43.0 -urllib3==1.25.8 -Werkzeug==1.0.0 -wrapt==1.12.1 +tifffile==2021.11.2 +tomli==1.2.2 +typing-extensions==4.0.0 +urllib3==1.26.7 +Werkzeug==2.0.2 +wrapt==1.13.3