keras-hub-nightly 0.16.0.dev20240915160609__py3-none-any.whl → 0.16.1.dev202409210335__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- keras_hub/__init__.py +0 -6
- keras_hub/api/__init__.py +1 -0
- keras_hub/api/utils/__init__.py +22 -0
- keras_hub/src/api_export.py +17 -11
- keras_hub/src/layers/preprocessing/resizing_image_converter.py +56 -6
- keras_hub/src/models/csp_darknet/csp_darknet_backbone.py +1 -11
- keras_hub/src/models/csp_darknet/csp_darknet_image_classifier.py +0 -1
- keras_hub/src/models/densenet/densenet_backbone.py +2 -12
- keras_hub/src/models/densenet/densenet_image_classifier.py +0 -1
- keras_hub/src/models/efficientnet/efficientnet_backbone.py +3 -14
- keras_hub/src/models/gemma/gemma_decoder_block.py +1 -1
- keras_hub/src/models/mix_transformer/mix_transformer_backbone.py +1 -11
- keras_hub/src/models/mix_transformer/mix_transformer_classifier.py +0 -1
- keras_hub/src/models/mobilenet/mobilenet_backbone.py +3 -14
- keras_hub/src/models/mobilenet/mobilenet_image_classifier.py +0 -1
- keras_hub/src/models/pali_gemma/pali_gemma_vit.py +3 -0
- keras_hub/src/models/resnet/resnet_backbone.py +1 -21
- keras_hub/src/models/resnet/resnet_image_classifier.py +9 -4
- keras_hub/src/models/resnet/resnet_presets.py +6 -6
- keras_hub/src/models/retinanet/__init__.py +13 -0
- keras_hub/src/models/retinanet/anchor_generator.py +175 -0
- keras_hub/src/models/retinanet/box_matcher.py +259 -0
- keras_hub/src/models/retinanet/non_max_supression.py +578 -0
- keras_hub/src/models/vgg/vgg_backbone.py +0 -8
- keras_hub/src/models/vgg/vgg_image_classifier.py +0 -1
- keras_hub/src/models/vit_det/vit_det_backbone.py +0 -9
- keras_hub/src/tests/test_case.py +11 -3
- keras_hub/src/tokenizers/byte_pair_tokenizer.py +1 -0
- keras_hub/src/tokenizers/sentence_piece_tokenizer.py +1 -0
- keras_hub/src/tokenizers/word_piece_tokenizer.py +1 -0
- keras_hub/src/utils/imagenet/__init__.py +13 -0
- keras_hub/src/utils/imagenet/imagenet_utils.py +1067 -0
- keras_hub/src/utils/preset_utils.py +10 -1
- keras_hub/src/utils/tensor_utils.py +14 -14
- keras_hub/src/utils/timm/convert_resnet.py +0 -8
- keras_hub/src/utils/timm/preset_loader.py +16 -1
- keras_hub/src/version_utils.py +1 -1
- keras_hub_nightly-0.16.1.dev202409210335.dist-info/METADATA +202 -0
- {keras_hub_nightly-0.16.0.dev20240915160609.dist-info → keras_hub_nightly-0.16.1.dev202409210335.dist-info}/RECORD +41 -34
- {keras_hub_nightly-0.16.0.dev20240915160609.dist-info → keras_hub_nightly-0.16.1.dev202409210335.dist-info}/WHEEL +1 -1
- keras_hub_nightly-0.16.0.dev20240915160609.dist-info/METADATA +0 -33
- {keras_hub_nightly-0.16.0.dev20240915160609.dist-info → keras_hub_nightly-0.16.1.dev202409210335.dist-info}/top_level.txt +0 -0
keras_hub/src/tests/test_case.py
CHANGED
@@ -600,6 +600,7 @@ class TestCase(tf.test.TestCase, parameterized.TestCase):
|
|
600
600
|
expected_output=None,
|
601
601
|
expected_output_shape=None,
|
602
602
|
expected_partial_output=None,
|
603
|
+
expected_labels=None,
|
603
604
|
):
|
604
605
|
"""Run instantiation and a forward pass for a preset."""
|
605
606
|
with self.assertRaises(Exception):
|
@@ -637,10 +638,17 @@ class TestCase(tf.test.TestCase, parameterized.TestCase):
|
|
637
638
|
|
638
639
|
tree.map_structure(compare, output, expected_partial_output)
|
639
640
|
|
641
|
+
if expected_labels is not None:
|
642
|
+
output = ops.argmax(output, axis=-1)
|
643
|
+
self.assertAllEqual(output, expected_labels)
|
644
|
+
|
640
645
|
def get_test_data_dir(self):
|
641
646
|
return str(pathlib.Path(__file__).parent / "test_data")
|
642
647
|
|
643
|
-
def load_test_image(self,
|
644
|
-
|
645
|
-
|
648
|
+
def load_test_image(self, target_size=None):
|
649
|
+
# From https://commons.wikimedia.org/wiki/File:California_quail.jpg
|
650
|
+
path = os.path.join(self.get_test_data_dir(), "test_image.jpg")
|
651
|
+
img = keras.utils.load_img(
|
652
|
+
path, target_size=target_size, keep_aspect_ratio=True
|
653
|
+
)
|
646
654
|
return np.array(img)
|
@@ -540,6 +540,7 @@ class BytePairTokenizer(tokenizer.Tokenizer):
|
|
540
540
|
if self.add_prefix_space:
|
541
541
|
inputs = tf.strings.join([" ", inputs])
|
542
542
|
|
543
|
+
inputs = tf.convert_to_tensor(inputs)
|
543
544
|
unbatched = inputs.shape.rank == 0
|
544
545
|
if unbatched:
|
545
546
|
inputs = tf.expand_dims(inputs, 0)
|
@@ -238,6 +238,7 @@ class SentencePieceTokenizer(tokenizer.Tokenizer):
|
|
238
238
|
@preprocessing_function
|
239
239
|
def tokenize(self, inputs):
|
240
240
|
self._check_vocabulary()
|
241
|
+
inputs = tf.convert_to_tensor(inputs)
|
241
242
|
unbatched = inputs.shape.rank == 0
|
242
243
|
if unbatched:
|
243
244
|
inputs = tf.expand_dims(inputs, 0)
|
@@ -473,6 +473,7 @@ class WordPieceTokenizer(tokenizer.Tokenizer):
|
|
473
473
|
@preprocessing_function
|
474
474
|
def tokenize(self, inputs):
|
475
475
|
self._check_vocabulary()
|
476
|
+
inputs = tf.convert_to_tensor(inputs)
|
476
477
|
unbatched = inputs.shape.rank == 0
|
477
478
|
pattern = None
|
478
479
|
if self.split and self.special_tokens_in_strings:
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Copyright 2024 The KerasNLP Authors
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|