titu1994 / keras-non-local-nets

Keras implementation of Non-local Neural Networks
MIT License
290 stars 100 forks source link

Refactor NonLocalBlock for Enhanced Modularity and Visualization #20

Closed andrewrgarcia closed 6 months ago

andrewrgarcia commented 6 months ago

This update aims to enhance the NonLocalBlock's usability in complex modeling pipelines, offering both detailed internal visibility for development and streamlined integration for production deployment.

*TLDR 🔥 💪🏼 : NonLocalBlocks instance has been made into a more formal Custom Layer by wrapping it with the tf.keras.layers.Layer subclass. A more modularized programming schema has been used, which makes the code more interpretable and may make it more maintainable to new developers. Given the new formal structure, NonLocalBlocks stands as a singular layer even on representations using plot_modelpackage from tensorflow.keras.utils (see plot_model-generated Image below where a very simple CNN is sandwiched between two NonLocalBlocks) Screenshot from 2024-05-12 16-20-04