diff --git a/.envrc b/.envrc old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.pylintrc b/.pylintrc old mode 100644 new mode 100755 index 309e38f..fda44bd --- a/.pylintrc +++ b/.pylintrc @@ -478,4 +478,4 @@ known-third-party=enchant # Exceptions that will emit a warning when being caught. Defaults to # "Exception" -overgeneral-exceptions=Exception +overgeneral-exceptions=builtins.Exception diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/config.yaml b/config.yaml old mode 100644 new mode 100755 index a168459..0a7c1ae --- a/config.yaml +++ b/config.yaml @@ -3,7 +3,7 @@ common_parameters: logging_output_directory_on_host: "/tmp/voc_ssd" voc: - data_directory: "../../data/VOC2012" + data_directory: "/data/VOC2012" train_set_path: "ImageSets/Main/train.txt" validation_set_path: "ImageSets/Main/val.txt" train_and_validation_set_path: "ImageSets/Main/trainval.txt" @@ -45,20 +45,20 @@ vggish_model_configuration: prediction_heads_order: ["block2_pool", "block3_pool", "block4_pool", "block5_pool"] block2_pool: image_downscale_factor: 4 - base_bounding_box_sizes: [20, 25] + base_bounding_box_sizes: [25] aspect_ratios: [0.6, 0.8, 1] block3_pool: image_downscale_factor: 8 - base_bounding_box_sizes: [30, 40, 50, 60] + base_bounding_box_sizes: [40, 50, 60] aspect_ratios: [0.6, 0.8, 1] block4_pool: image_downscale_factor: 16 base_bounding_box_sizes: [80, 100, 120] - aspect_ratios: [0.4, 0.6, 0.8, 1] + aspect_ratios: [0.6, 0.8, 1] block5_pool: image_downscale_factor: 32 base_bounding_box_sizes: [150, 200, 300, 400, 500] - aspect_ratios: [0.4, 0.6, 0.8, 1] + aspect_ratios: [0.6, 0.8, 1] resnetish_model_configuration: @@ -88,5 +88,5 @@ train: reduce_learning_rate_patience: 2 reduce_learning_rate_factor: 0.1 -model_checkpoint_path: "../../data/voc_ssd_models/current_model/" -best_model_checkpoint_path: "../../data/voc_ssd_models/current_model/" +model_checkpoint_path: "/data/voc_ssd_models/current_model.weights.h5" +best_model_checkpoint_path: "/data/voc_ssd_models/current_model/" diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index 84afe31..b2c467d 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -2,7 +2,7 @@ FROM tensorflow/tensorflow:2.9.1-gpu # Install a few necessary need or useful libs and apps -RUN apt update && apt install -y libcairo2-dev wget libgl1 +RUN apt update && apt install -y git libcairo2-dev wget libgl1 # Download base tensorflow models RUN mkdir -p /root/.keras/models && \ diff --git a/net/__init__.py b/net/__init__.py old mode 100644 new mode 100755 diff --git a/net/logging.py b/net/logging.py index 021621d..97c256a 100644 --- a/net/logging.py +++ b/net/logging.py @@ -6,6 +6,7 @@ import net.data import net.plot +import net.ssd import net.utilities diff --git a/net/ml.py b/net/ml.py old mode 100644 new mode 100755 index ae3967f..d9bf736 --- a/net/ml.py +++ b/net/ml.py @@ -83,18 +83,14 @@ def __init__(self, model_configuration, categories_count): categories_predictions_heads_ops_list.append(categories_predictions_head) offset_predictions_heads_ops_list.append(offsets_predictions_head) - self.batch_of_categories_predictions_logits_matrices_op = \ - tf.concat(categories_predictions_heads_ops_list, axis=1) + self.batch_of_categories_predictions_logits_matrices_op = tf.keras.layers.Concatenate( + axis=1, name="categories_prediction_logits_head")(categories_predictions_heads_ops_list) - self.batch_of_softmax_categories_predictions_matrices_op = tf.nn.softmax( - logits=self.batch_of_categories_predictions_logits_matrices_op, - axis=-1, - name="categories_predictions_head") + self.batch_of_softmax_categories_predictions_matrices_op = tf.keras.layers.Softmax( + axis=-1, name="categories_predictions_head")(self.batch_of_categories_predictions_logits_matrices_op) - self.batch_of_offsets_predictions_matrices_op = tf.concat( - values=offset_predictions_heads_ops_list, - axis=1, - name="offsets_predictions_head") + self.batch_of_offsets_predictions_matrices_op = tf.keras.layers.Concatenate( + axis=1, name="offsets_predictions_head")(offset_predictions_heads_ops_list) self.model = tf.keras.models.Model( inputs=self.input_placeholder, @@ -144,13 +140,9 @@ def get_predictions_head(input_op, categories_count, head_configuration): offsets_predictions_op = tf.keras.layers.Conv2D( filters=4 * default_boxes_count, kernel_size=(3, 3), padding='same')(x) - # Reshape outputs to 3D matrices (batch_dimension, default boxes on all pixel locations, x), where - # x is categories_count for categories logits predictions op and 4 for offsets predictions op return \ - tf.reshape(categories_logits_predictions_op, - shape=(tf.shape(categories_logits_predictions_op)[0], -1, categories_count)), \ - tf.reshape(offsets_predictions_op, - shape=(tf.shape(offsets_predictions_op)[0], -1, 4)) + tf.keras.layers.Reshape((-1, categories_count))(categories_logits_predictions_op), \ + tf.keras.layers.Reshape((-1, 4))(offsets_predictions_op) def get_base_layers_tensors_map(self): """ diff --git a/net/plot.py b/net/plot.py old mode 100644 new mode 100755 index 26823ce..391084e --- a/net/plot.py +++ b/net/plot.py @@ -22,15 +22,18 @@ def draw_annotation_label(pil_image, annotation, color, font): draw_manager = PIL.ImageDraw.Draw(pil_image) - text_size = draw_manager.textsize(annotation.label, font) + dummy_text_box = draw_manager.textbbox((0, 0), annotation.label, font) + + text_width = dummy_text_box[2] - dummy_text_box[0] + text_height = dummy_text_box[3] - dummy_text_box[1] box_left = int(max(0, np.floor(annotation.bounding_box[0] + 0.5))) box_top = int(max(0, np.floor(annotation.bounding_box[1] + 0.5))) - text_origin = [box_left, box_top - text_size[1]] \ - if box_top - text_size[1] >= 0 else [box_left, box_top + 1] + text_origin = [box_left, box_top - text_height] \ + if box_top - text_height >= 0 else [box_left, box_top + 1] - text_end = text_origin[0] + text_size[0], text_origin[1] + text_size[1] + text_end = text_origin[0] + text_width, text_origin[1] + text_height text_box = text_origin[0], text_origin[1], text_end[0], text_end[1] draw_manager.rectangle(text_box, fill=tuple(color)) diff --git a/net/ssd.py b/net/ssd.py old mode 100644 new mode 100755 diff --git a/net/utilities.py b/net/utilities.py old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt index 67b99c8..22d2fa1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,81 +1,82 @@ absl-py==1.0.0 antlr4-python3-runtime==4.9.3 -astroid==2.12.13 +astroid==3.2.4 +asttokens==2.4.1 astunparse==1.6.3 -attrs==22.1.0 cachetools==5.1.0 certifi==2019.11.28 chardet==3.0.4 colorama==0.4.6 -contourpy==1.0.6 -cycler==0.11.0 +contourpy==1.1.1 +cycler==0.12.1 dbus-python==1.2.16 -dill==0.3.6 -exceptiongroup==1.0.4 +dill==0.3.9 +exceptiongroup==1.2.2 +executing==2.1.0 flatbuffers==1.12 -fonttools==4.38.0 -future==0.18.2 +fonttools==4.55.0 gast==0.4.0 -gitdb==4.0.10 -GitPython==3.1.29 +gitdb==4.0.11 +GitPython==3.1.43 google-auth==2.6.6 google-auth-oauthlib==0.4.6 google-pasta==0.2.0 grpcio==1.46.3 h5py==3.6.0 +icecream==2.1.3 idna==2.8 -imageio==2.22.4 +imageio==2.35.1 imgaug==0.4.0 importlib-metadata==4.11.4 -iniconfig==1.1.1 -invoke==1.7.3 -isort==5.10.1 +importlib-resources==6.4.5 +iniconfig==2.0.0 +invoke==2.2.0 +isort==5.13.2 keras==2.9.0 Keras-Preprocessing==1.1.2 -kiwisolver==1.4.4 -lazy-object-proxy==1.8.0 +kiwisolver==1.4.7 +lazy-loader==0.4 libclang==14.0.1 -mando==0.6.4 +mando==0.7.1 Markdown==3.3.7 -matplotlib==3.6.2 +matplotlib==3.7.5 mccabe==0.7.0 -networkx==2.8.8 +networkx==3.1 numpy==1.22.4 oauthlib==3.2.0 -omegaconf==2.2.3 -opencv-python==4.6.0.66 -opencv-python-headless==4.6.0.66 +omegaconf==2.3.0 +opencv-python==4.10.0.84 opt-einsum==3.3.0 packaging==21.3 -pandas==1.5.2 -Pillow==9.3.0 -platformdirs==2.5.4 -pluggy==1.0.0 +pandas==2.0.3 +pillow==10.4.0 +platformdirs==4.3.6 +pluggy==1.5.0 protobuf==3.19.4 pyasn1==0.4.8 pyasn1-modules==0.2.8 -pycairo==1.23.0 -pycodestyle==2.10.0 +pycodestyle==2.12.1 +pygments==2.18.0 PyGObject==3.36.0 -pylint==2.15.7 +pylint==3.2.7 pyparsing==3.0.9 -pytest==7.2.0 +pytest==8.3.3 python-apt==2.0.0+ubuntu0.20.4.7 -python-dateutil==2.8.2 -pytz==2022.6 +python-dateutil==2.9.0.post0 +pytz==2024.2 PyWavelets==1.4.1 -PyYAML==6.0 -radon==5.1.0 +PyYAML==6.0.2 +radon==6.0.1 requests==2.22.0 requests-oauthlib==1.3.1 requests-unixsocket==0.2.0 rsa==4.8 -scikit-image==0.19.3 -scipy==1.9.3 -seaborn==0.12.1 -Shapely==1.8.5.post1 +scikit-image==0.21.0 +scipy==1.10.1 +seaborn==0.13.2 +shapely==2.0.6 six==1.14.0 -smmap==5.0.0 +smmap==5.0.1 tensorboard==2.9.0 tensorboard-data-server==0.6.1 tensorboard-plugin-wit==1.8.1 @@ -83,15 +84,16 @@ tensorflow==2.9.1 tensorflow-estimator==2.9.0 tensorflow-io-gcs-filesystem==0.26.0 termcolor==1.1.0 -tifffile==2022.10.10 -tomli==2.0.1 -tomlkit==0.11.6 -tqdm==4.64.1 +tifffile==2023.7.10 +tomli==2.2.1 +tomlkit==0.13.2 +tqdm==4.67.1 typing-extensions==4.2.0 +tzdata==2024.2 urllib3==1.25.8 visual-logging==1.0 Werkzeug==2.1.2 wrapt==1.14.1 -xenon==0.9.0 -xmltodict==0.13.0 +xenon==0.9.3 +xmltodict==0.14.2 zipp==3.8.0 diff --git a/setup.cfg b/setup.cfg old mode 100644 new mode 100755 diff --git a/tests/__init__.py b/tests/__init__.py old mode 100644 new mode 100755 diff --git a/tests/commit_stage/__init__.py b/tests/commit_stage/__init__.py old mode 100644 new mode 100755 diff --git a/tests/commit_stage/unit_tests/__init__.py b/tests/commit_stage/unit_tests/__init__.py old mode 100644 new mode 100755 diff --git a/tests/commit_stage/unit_tests/test_utilities.py b/tests/commit_stage/unit_tests/test_utilities.py old mode 100644 new mode 100755