diff --git a/.gitignore b/.gitignore index 566d9d109e..110279bcbe 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ wheels .devcontainer/ .coverage .history + +# Common env config file use by pyenv +.python_version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000..14348698da --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +keras diff --git a/examples/layers/preprocessing/bounding_box/demo_utils.py b/examples/layers/preprocessing/bounding_box/demo_utils.py index e0dad414bf..2eb9cad71f 100644 --- a/examples/layers/preprocessing/bounding_box/demo_utils.py +++ b/examples/layers/preprocessing/bounding_box/demo_utils.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. """Utility functions for preprocessing demos.""" +import math + import matplotlib.pyplot as plt import numpy as np import tensorflow as tf @@ -84,9 +86,13 @@ def visualize_bounding_boxes(image, bounding_boxes, bounding_box_format): def gallery_show(images): images = images.astype(int) - for i in range(9): + image_count = len(images) + max_columns = 3 + cols = min(image_count, max_columns) + rows = math.ceil(image_count / max_columns) + for i in range(len(images)): image = images[i] - plt.subplot(3, 3, i + 1) + plt.subplot(rows, cols, i + 1) plt.imshow(image.astype("uint8")) plt.axis("off") plt.show()