keras-hub-nightly 0.16.1.dev202409260340__py3-none-any.whl → 0.16.1.dev202409280337__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 -13
- keras_hub/api/__init__.py +0 -13
- keras_hub/api/bounding_box/__init__.py +0 -13
- keras_hub/api/layers/__init__.py +0 -13
- keras_hub/api/metrics/__init__.py +0 -13
- keras_hub/api/models/__init__.py +0 -13
- keras_hub/api/samplers/__init__.py +0 -13
- keras_hub/api/tokenizers/__init__.py +0 -13
- keras_hub/api/utils/__init__.py +0 -13
- keras_hub/src/__init__.py +0 -13
- keras_hub/src/api_export.py +0 -14
- keras_hub/src/bounding_box/__init__.py +0 -13
- keras_hub/src/bounding_box/converters.py +0 -13
- keras_hub/src/bounding_box/formats.py +0 -13
- keras_hub/src/bounding_box/iou.py +1 -13
- keras_hub/src/bounding_box/to_dense.py +0 -14
- keras_hub/src/bounding_box/to_ragged.py +0 -13
- keras_hub/src/bounding_box/utils.py +0 -13
- keras_hub/src/bounding_box/validate_format.py +0 -14
- keras_hub/src/layers/__init__.py +0 -13
- keras_hub/src/layers/modeling/__init__.py +0 -13
- keras_hub/src/layers/modeling/alibi_bias.py +0 -13
- keras_hub/src/layers/modeling/cached_multi_head_attention.py +0 -14
- keras_hub/src/layers/modeling/f_net_encoder.py +0 -14
- keras_hub/src/layers/modeling/masked_lm_head.py +0 -14
- keras_hub/src/layers/modeling/position_embedding.py +0 -14
- keras_hub/src/layers/modeling/reversible_embedding.py +0 -14
- keras_hub/src/layers/modeling/rotary_embedding.py +0 -14
- keras_hub/src/layers/modeling/sine_position_encoding.py +0 -14
- keras_hub/src/layers/modeling/token_and_position_embedding.py +0 -14
- keras_hub/src/layers/modeling/transformer_decoder.py +0 -14
- keras_hub/src/layers/modeling/transformer_encoder.py +0 -14
- keras_hub/src/layers/modeling/transformer_layer_utils.py +0 -14
- keras_hub/src/layers/preprocessing/__init__.py +0 -13
- keras_hub/src/layers/preprocessing/audio_converter.py +0 -13
- keras_hub/src/layers/preprocessing/image_converter.py +0 -13
- keras_hub/src/layers/preprocessing/masked_lm_mask_generator.py +0 -15
- keras_hub/src/layers/preprocessing/multi_segment_packer.py +0 -14
- keras_hub/src/layers/preprocessing/preprocessing_layer.py +0 -14
- keras_hub/src/layers/preprocessing/random_deletion.py +0 -14
- keras_hub/src/layers/preprocessing/random_swap.py +0 -14
- keras_hub/src/layers/preprocessing/resizing_image_converter.py +0 -13
- keras_hub/src/layers/preprocessing/start_end_packer.py +0 -15
- keras_hub/src/metrics/__init__.py +0 -13
- keras_hub/src/metrics/bleu.py +0 -14
- keras_hub/src/metrics/edit_distance.py +0 -14
- keras_hub/src/metrics/perplexity.py +0 -14
- keras_hub/src/metrics/rouge_base.py +0 -14
- keras_hub/src/metrics/rouge_l.py +0 -14
- keras_hub/src/metrics/rouge_n.py +0 -14
- keras_hub/src/models/__init__.py +0 -13
- keras_hub/src/models/albert/__init__.py +0 -14
- keras_hub/src/models/albert/albert_backbone.py +0 -14
- keras_hub/src/models/albert/albert_masked_lm.py +0 -14
- keras_hub/src/models/albert/albert_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/albert/albert_presets.py +0 -14
- keras_hub/src/models/albert/albert_text_classifier.py +0 -14
- keras_hub/src/models/albert/albert_text_classifier_preprocessor.py +0 -14
- keras_hub/src/models/albert/albert_tokenizer.py +0 -14
- keras_hub/src/models/backbone.py +0 -14
- keras_hub/src/models/bart/__init__.py +0 -14
- keras_hub/src/models/bart/bart_backbone.py +0 -14
- keras_hub/src/models/bart/bart_presets.py +0 -13
- keras_hub/src/models/bart/bart_seq_2_seq_lm.py +0 -15
- keras_hub/src/models/bart/bart_seq_2_seq_lm_preprocessor.py +0 -15
- keras_hub/src/models/bart/bart_tokenizer.py +0 -15
- keras_hub/src/models/bert/__init__.py +0 -14
- keras_hub/src/models/bert/bert_backbone.py +0 -14
- keras_hub/src/models/bert/bert_masked_lm.py +0 -14
- keras_hub/src/models/bert/bert_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/bert/bert_presets.py +0 -13
- keras_hub/src/models/bert/bert_text_classifier.py +0 -14
- keras_hub/src/models/bert/bert_text_classifier_preprocessor.py +0 -14
- keras_hub/src/models/bert/bert_tokenizer.py +0 -14
- keras_hub/src/models/bloom/__init__.py +0 -14
- keras_hub/src/models/bloom/bloom_attention.py +0 -13
- keras_hub/src/models/bloom/bloom_backbone.py +0 -14
- keras_hub/src/models/bloom/bloom_causal_lm.py +0 -15
- keras_hub/src/models/bloom/bloom_causal_lm_preprocessor.py +0 -15
- keras_hub/src/models/bloom/bloom_decoder.py +0 -13
- keras_hub/src/models/bloom/bloom_presets.py +0 -13
- keras_hub/src/models/bloom/bloom_tokenizer.py +0 -15
- keras_hub/src/models/causal_lm.py +0 -14
- keras_hub/src/models/causal_lm_preprocessor.py +0 -13
- keras_hub/src/models/clip/__init__.py +0 -13
- keras_hub/src/models/clip/clip_encoder_block.py +0 -13
- keras_hub/src/models/clip/clip_preprocessor.py +1 -14
- keras_hub/src/models/clip/clip_text_encoder.py +0 -13
- keras_hub/src/models/clip/clip_tokenizer.py +4 -19
- keras_hub/src/models/csp_darknet/__init__.py +0 -13
- keras_hub/src/models/csp_darknet/csp_darknet_backbone.py +0 -13
- keras_hub/src/models/csp_darknet/csp_darknet_image_classifier.py +0 -13
- keras_hub/src/models/deberta_v3/__init__.py +0 -14
- keras_hub/src/models/deberta_v3/deberta_v3_backbone.py +0 -15
- keras_hub/src/models/deberta_v3/deberta_v3_masked_lm.py +0 -15
- keras_hub/src/models/deberta_v3/deberta_v3_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/deberta_v3/deberta_v3_presets.py +0 -13
- keras_hub/src/models/deberta_v3/deberta_v3_text_classifier.py +0 -15
- keras_hub/src/models/deberta_v3/deberta_v3_text_classifier_preprocessor.py +0 -14
- keras_hub/src/models/deberta_v3/deberta_v3_tokenizer.py +0 -15
- keras_hub/src/models/deberta_v3/disentangled_attention_encoder.py +0 -14
- keras_hub/src/models/deberta_v3/disentangled_self_attention.py +0 -14
- keras_hub/src/models/deberta_v3/relative_embedding.py +0 -14
- keras_hub/src/models/densenet/__init__.py +0 -14
- keras_hub/src/models/densenet/densenet_backbone.py +0 -13
- keras_hub/src/models/densenet/densenet_image_classifier.py +0 -13
- keras_hub/src/models/densenet/densenet_image_classifier_preprocessor.py +0 -13
- keras_hub/src/models/densenet/densenet_image_converter.py +0 -13
- keras_hub/src/models/densenet/densenet_presets.py +0 -13
- keras_hub/src/models/distil_bert/__init__.py +0 -14
- keras_hub/src/models/distil_bert/distil_bert_backbone.py +0 -15
- keras_hub/src/models/distil_bert/distil_bert_masked_lm.py +0 -15
- keras_hub/src/models/distil_bert/distil_bert_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/distil_bert/distil_bert_presets.py +0 -13
- keras_hub/src/models/distil_bert/distil_bert_text_classifier.py +0 -15
- keras_hub/src/models/distil_bert/distil_bert_text_classifier_preprocessor.py +0 -15
- keras_hub/src/models/distil_bert/distil_bert_tokenizer.py +0 -15
- keras_hub/src/models/efficientnet/__init__.py +0 -13
- keras_hub/src/models/efficientnet/efficientnet_backbone.py +0 -13
- keras_hub/src/models/efficientnet/fusedmbconv.py +0 -14
- keras_hub/src/models/efficientnet/mbconv.py +0 -14
- keras_hub/src/models/electra/__init__.py +0 -14
- keras_hub/src/models/electra/electra_backbone.py +0 -14
- keras_hub/src/models/electra/electra_presets.py +0 -13
- keras_hub/src/models/electra/electra_tokenizer.py +0 -14
- keras_hub/src/models/f_net/__init__.py +0 -14
- keras_hub/src/models/f_net/f_net_backbone.py +0 -15
- keras_hub/src/models/f_net/f_net_masked_lm.py +0 -15
- keras_hub/src/models/f_net/f_net_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/f_net/f_net_presets.py +0 -13
- keras_hub/src/models/f_net/f_net_text_classifier.py +0 -15
- keras_hub/src/models/f_net/f_net_text_classifier_preprocessor.py +0 -15
- keras_hub/src/models/f_net/f_net_tokenizer.py +0 -15
- keras_hub/src/models/falcon/__init__.py +0 -14
- keras_hub/src/models/falcon/falcon_attention.py +0 -13
- keras_hub/src/models/falcon/falcon_backbone.py +0 -13
- keras_hub/src/models/falcon/falcon_causal_lm.py +0 -14
- keras_hub/src/models/falcon/falcon_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/falcon/falcon_presets.py +0 -13
- keras_hub/src/models/falcon/falcon_tokenizer.py +0 -15
- keras_hub/src/models/falcon/falcon_transformer_decoder.py +0 -13
- keras_hub/src/models/feature_pyramid_backbone.py +0 -13
- keras_hub/src/models/gemma/__init__.py +0 -14
- keras_hub/src/models/gemma/gemma_attention.py +0 -13
- keras_hub/src/models/gemma/gemma_backbone.py +0 -15
- keras_hub/src/models/gemma/gemma_causal_lm.py +0 -15
- keras_hub/src/models/gemma/gemma_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/gemma/gemma_decoder_block.py +0 -13
- keras_hub/src/models/gemma/gemma_presets.py +0 -13
- keras_hub/src/models/gemma/gemma_tokenizer.py +0 -14
- keras_hub/src/models/gemma/rms_normalization.py +0 -14
- keras_hub/src/models/gpt2/__init__.py +0 -14
- keras_hub/src/models/gpt2/gpt2_backbone.py +0 -15
- keras_hub/src/models/gpt2/gpt2_causal_lm.py +0 -15
- keras_hub/src/models/gpt2/gpt2_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/gpt2/gpt2_preprocessor.py +0 -15
- keras_hub/src/models/gpt2/gpt2_presets.py +0 -13
- keras_hub/src/models/gpt2/gpt2_tokenizer.py +0 -15
- keras_hub/src/models/gpt_neo_x/__init__.py +0 -13
- keras_hub/src/models/gpt_neo_x/gpt_neo_x_attention.py +0 -14
- keras_hub/src/models/gpt_neo_x/gpt_neo_x_backbone.py +0 -14
- keras_hub/src/models/gpt_neo_x/gpt_neo_x_causal_lm.py +0 -14
- keras_hub/src/models/gpt_neo_x/gpt_neo_x_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/gpt_neo_x/gpt_neo_x_decoder.py +0 -14
- keras_hub/src/models/gpt_neo_x/gpt_neo_x_tokenizer.py +0 -14
- keras_hub/src/models/image_classifier.py +0 -13
- keras_hub/src/models/image_classifier_preprocessor.py +0 -13
- keras_hub/src/models/image_segmenter.py +0 -13
- keras_hub/src/models/llama/__init__.py +0 -14
- keras_hub/src/models/llama/llama_attention.py +0 -13
- keras_hub/src/models/llama/llama_backbone.py +0 -13
- keras_hub/src/models/llama/llama_causal_lm.py +0 -13
- keras_hub/src/models/llama/llama_causal_lm_preprocessor.py +0 -15
- keras_hub/src/models/llama/llama_decoder.py +0 -13
- keras_hub/src/models/llama/llama_layernorm.py +0 -13
- keras_hub/src/models/llama/llama_presets.py +0 -13
- keras_hub/src/models/llama/llama_tokenizer.py +0 -14
- keras_hub/src/models/llama3/__init__.py +0 -14
- keras_hub/src/models/llama3/llama3_backbone.py +0 -14
- keras_hub/src/models/llama3/llama3_causal_lm.py +0 -13
- keras_hub/src/models/llama3/llama3_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/llama3/llama3_presets.py +0 -13
- keras_hub/src/models/llama3/llama3_tokenizer.py +0 -14
- keras_hub/src/models/masked_lm.py +0 -13
- keras_hub/src/models/masked_lm_preprocessor.py +0 -13
- keras_hub/src/models/mistral/__init__.py +0 -14
- keras_hub/src/models/mistral/mistral_attention.py +0 -13
- keras_hub/src/models/mistral/mistral_backbone.py +0 -14
- keras_hub/src/models/mistral/mistral_causal_lm.py +0 -14
- keras_hub/src/models/mistral/mistral_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/mistral/mistral_layer_norm.py +0 -13
- keras_hub/src/models/mistral/mistral_presets.py +0 -13
- keras_hub/src/models/mistral/mistral_tokenizer.py +0 -14
- keras_hub/src/models/mistral/mistral_transformer_decoder.py +0 -13
- keras_hub/src/models/mix_transformer/__init__.py +0 -13
- keras_hub/src/models/mix_transformer/mix_transformer_backbone.py +0 -13
- keras_hub/src/models/mix_transformer/mix_transformer_classifier.py +0 -13
- keras_hub/src/models/mix_transformer/mix_transformer_layers.py +0 -13
- keras_hub/src/models/mobilenet/__init__.py +0 -13
- keras_hub/src/models/mobilenet/mobilenet_backbone.py +0 -13
- keras_hub/src/models/mobilenet/mobilenet_image_classifier.py +0 -13
- keras_hub/src/models/opt/__init__.py +0 -14
- keras_hub/src/models/opt/opt_backbone.py +0 -15
- keras_hub/src/models/opt/opt_causal_lm.py +0 -15
- keras_hub/src/models/opt/opt_causal_lm_preprocessor.py +0 -13
- keras_hub/src/models/opt/opt_presets.py +0 -13
- keras_hub/src/models/opt/opt_tokenizer.py +0 -15
- keras_hub/src/models/pali_gemma/__init__.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_backbone.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_causal_lm.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_causal_lm_preprocessor.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_decoder_block.py +0 -14
- keras_hub/src/models/pali_gemma/pali_gemma_image_converter.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_presets.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_tokenizer.py +0 -13
- keras_hub/src/models/pali_gemma/pali_gemma_vit.py +0 -13
- keras_hub/src/models/phi3/__init__.py +0 -14
- keras_hub/src/models/phi3/phi3_attention.py +0 -13
- keras_hub/src/models/phi3/phi3_backbone.py +0 -13
- keras_hub/src/models/phi3/phi3_causal_lm.py +0 -13
- keras_hub/src/models/phi3/phi3_causal_lm_preprocessor.py +0 -14
- keras_hub/src/models/phi3/phi3_decoder.py +0 -13
- keras_hub/src/models/phi3/phi3_layernorm.py +0 -13
- keras_hub/src/models/phi3/phi3_presets.py +0 -13
- keras_hub/src/models/phi3/phi3_rotary_embedding.py +0 -13
- keras_hub/src/models/phi3/phi3_tokenizer.py +0 -13
- keras_hub/src/models/preprocessor.py +51 -32
- keras_hub/src/models/resnet/__init__.py +0 -14
- keras_hub/src/models/resnet/resnet_backbone.py +0 -13
- keras_hub/src/models/resnet/resnet_image_classifier.py +0 -13
- keras_hub/src/models/resnet/resnet_image_classifier_preprocessor.py +0 -14
- keras_hub/src/models/resnet/resnet_image_converter.py +0 -13
- keras_hub/src/models/resnet/resnet_presets.py +0 -13
- keras_hub/src/models/retinanet/__init__.py +0 -13
- keras_hub/src/models/retinanet/anchor_generator.py +28 -30
- keras_hub/src/models/retinanet/box_matcher.py +0 -14
- keras_hub/src/models/retinanet/feature_pyramid.py +373 -0
- keras_hub/src/models/retinanet/non_max_supression.py +0 -14
- keras_hub/src/models/retinanet/retinanet_label_encoder.py +270 -0
- keras_hub/src/models/roberta/__init__.py +0 -14
- keras_hub/src/models/roberta/roberta_backbone.py +0 -15
- keras_hub/src/models/roberta/roberta_masked_lm.py +0 -15
- keras_hub/src/models/roberta/roberta_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/roberta/roberta_presets.py +0 -13
- keras_hub/src/models/roberta/roberta_text_classifier.py +0 -15
- keras_hub/src/models/roberta/roberta_text_classifier_preprocessor.py +0 -14
- keras_hub/src/models/roberta/roberta_tokenizer.py +0 -15
- keras_hub/src/models/sam/__init__.py +0 -13
- keras_hub/src/models/sam/sam_backbone.py +0 -14
- keras_hub/src/models/sam/sam_image_segmenter.py +0 -14
- keras_hub/src/models/sam/sam_layers.py +0 -14
- keras_hub/src/models/sam/sam_mask_decoder.py +0 -14
- keras_hub/src/models/sam/sam_prompt_encoder.py +0 -14
- keras_hub/src/models/sam/sam_transformer.py +0 -14
- keras_hub/src/models/seq_2_seq_lm.py +0 -13
- keras_hub/src/models/seq_2_seq_lm_preprocessor.py +0 -13
- keras_hub/src/models/stable_diffusion_3/__init__.py +9 -13
- keras_hub/src/models/stable_diffusion_3/flow_match_euler_discrete_scheduler.py +0 -13
- keras_hub/src/models/stable_diffusion_3/mmdit.py +0 -13
- keras_hub/src/models/stable_diffusion_3/stable_diffusion_3_backbone.py +15 -14
- keras_hub/src/models/stable_diffusion_3/stable_diffusion_3_presets.py +18 -0
- keras_hub/src/models/stable_diffusion_3/stable_diffusion_3_text_to_image.py +0 -13
- keras_hub/src/models/stable_diffusion_3/stable_diffusion_3_text_to_image_preprocessor.py +23 -17
- keras_hub/src/models/stable_diffusion_3/t5_encoder.py +0 -13
- keras_hub/src/models/stable_diffusion_3/vae_image_decoder.py +0 -13
- keras_hub/src/models/t5/__init__.py +0 -14
- keras_hub/src/models/t5/t5_backbone.py +0 -14
- keras_hub/src/models/t5/t5_layer_norm.py +0 -14
- keras_hub/src/models/t5/t5_multi_head_attention.py +0 -14
- keras_hub/src/models/t5/t5_preprocessor.py +0 -13
- keras_hub/src/models/t5/t5_presets.py +0 -13
- keras_hub/src/models/t5/t5_tokenizer.py +0 -14
- keras_hub/src/models/t5/t5_transformer_layer.py +0 -14
- keras_hub/src/models/task.py +0 -14
- keras_hub/src/models/text_classifier.py +0 -13
- keras_hub/src/models/text_classifier_preprocessor.py +0 -13
- keras_hub/src/models/text_to_image.py +0 -13
- keras_hub/src/models/vgg/__init__.py +0 -13
- keras_hub/src/models/vgg/vgg_backbone.py +0 -13
- keras_hub/src/models/vgg/vgg_image_classifier.py +0 -13
- keras_hub/src/models/vit_det/__init__.py +0 -13
- keras_hub/src/models/vit_det/vit_det_backbone.py +0 -14
- keras_hub/src/models/vit_det/vit_layers.py +0 -15
- keras_hub/src/models/whisper/__init__.py +0 -14
- keras_hub/src/models/whisper/whisper_audio_converter.py +0 -15
- keras_hub/src/models/whisper/whisper_backbone.py +0 -15
- keras_hub/src/models/whisper/whisper_cached_multi_head_attention.py +0 -13
- keras_hub/src/models/whisper/whisper_decoder.py +0 -14
- keras_hub/src/models/whisper/whisper_encoder.py +0 -14
- keras_hub/src/models/whisper/whisper_presets.py +0 -14
- keras_hub/src/models/whisper/whisper_tokenizer.py +0 -14
- keras_hub/src/models/xlm_roberta/__init__.py +0 -14
- keras_hub/src/models/xlm_roberta/xlm_roberta_backbone.py +0 -15
- keras_hub/src/models/xlm_roberta/xlm_roberta_masked_lm.py +0 -15
- keras_hub/src/models/xlm_roberta/xlm_roberta_masked_lm_preprocessor.py +0 -14
- keras_hub/src/models/xlm_roberta/xlm_roberta_presets.py +0 -13
- keras_hub/src/models/xlm_roberta/xlm_roberta_text_classifier.py +0 -15
- keras_hub/src/models/xlm_roberta/xlm_roberta_text_classifier_preprocessor.py +0 -15
- keras_hub/src/models/xlm_roberta/xlm_roberta_tokenizer.py +0 -15
- keras_hub/src/models/xlnet/__init__.py +0 -13
- keras_hub/src/models/xlnet/relative_attention.py +0 -14
- keras_hub/src/models/xlnet/xlnet_backbone.py +0 -14
- keras_hub/src/models/xlnet/xlnet_content_and_query_embedding.py +0 -14
- keras_hub/src/models/xlnet/xlnet_encoder.py +0 -14
- keras_hub/src/samplers/__init__.py +0 -13
- keras_hub/src/samplers/beam_sampler.py +0 -14
- keras_hub/src/samplers/contrastive_sampler.py +0 -14
- keras_hub/src/samplers/greedy_sampler.py +0 -14
- keras_hub/src/samplers/random_sampler.py +0 -14
- keras_hub/src/samplers/sampler.py +0 -14
- keras_hub/src/samplers/serialization.py +0 -14
- keras_hub/src/samplers/top_k_sampler.py +0 -14
- keras_hub/src/samplers/top_p_sampler.py +0 -14
- keras_hub/src/tests/__init__.py +0 -13
- keras_hub/src/tests/test_case.py +23 -20
- keras_hub/src/tokenizers/__init__.py +0 -13
- keras_hub/src/tokenizers/byte_pair_tokenizer.py +0 -14
- keras_hub/src/tokenizers/byte_tokenizer.py +0 -14
- keras_hub/src/tokenizers/sentence_piece_tokenizer.py +0 -14
- keras_hub/src/tokenizers/sentence_piece_tokenizer_trainer.py +0 -14
- keras_hub/src/tokenizers/tokenizer.py +23 -27
- keras_hub/src/tokenizers/unicode_codepoint_tokenizer.py +0 -15
- keras_hub/src/tokenizers/word_piece_tokenizer.py +0 -14
- keras_hub/src/tokenizers/word_piece_tokenizer_trainer.py +0 -15
- keras_hub/src/utils/__init__.py +0 -13
- keras_hub/src/utils/imagenet/__init__.py +0 -13
- keras_hub/src/utils/imagenet/imagenet_utils.py +0 -13
- keras_hub/src/utils/keras_utils.py +0 -14
- keras_hub/src/utils/pipeline_model.py +0 -14
- keras_hub/src/utils/preset_utils.py +32 -76
- keras_hub/src/utils/python_utils.py +0 -13
- keras_hub/src/utils/tensor_utils.py +106 -14
- keras_hub/src/utils/timm/__init__.py +0 -13
- keras_hub/src/utils/timm/convert_densenet.py +0 -13
- keras_hub/src/utils/timm/convert_resnet.py +0 -13
- keras_hub/src/utils/timm/preset_loader.py +0 -13
- keras_hub/src/utils/transformers/__init__.py +0 -13
- keras_hub/src/utils/transformers/convert_albert.py +0 -13
- keras_hub/src/utils/transformers/convert_bart.py +0 -13
- keras_hub/src/utils/transformers/convert_bert.py +0 -13
- keras_hub/src/utils/transformers/convert_distilbert.py +0 -13
- keras_hub/src/utils/transformers/convert_gemma.py +0 -13
- keras_hub/src/utils/transformers/convert_gpt2.py +0 -13
- keras_hub/src/utils/transformers/convert_llama3.py +0 -13
- keras_hub/src/utils/transformers/convert_mistral.py +0 -13
- keras_hub/src/utils/transformers/convert_pali_gemma.py +0 -13
- keras_hub/src/utils/transformers/preset_loader.py +1 -15
- keras_hub/src/utils/transformers/safetensor_utils.py +9 -15
- keras_hub/src/version_utils.py +1 -15
- {keras_hub_nightly-0.16.1.dev202409260340.dist-info → keras_hub_nightly-0.16.1.dev202409280337.dist-info}/METADATA +30 -27
- keras_hub_nightly-0.16.1.dev202409280337.dist-info/RECORD +353 -0
- keras_hub_nightly-0.16.1.dev202409260340.dist-info/RECORD +0 -350
- {keras_hub_nightly-0.16.1.dev202409260340.dist-info → keras_hub_nightly-0.16.1.dev202409280337.dist-info}/WHEEL +0 -0
- {keras_hub_nightly-0.16.1.dev202409260340.dist-info → keras_hub_nightly-0.16.1.dev202409280337.dist-info}/top_level.txt +0 -0
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
|
-
|
15
1
|
import collections
|
16
2
|
import datetime
|
17
3
|
import inspect
|
@@ -55,7 +41,8 @@ KAGGLE_SCHEME = "kaggle"
|
|
55
41
|
GS_SCHEME = "gs"
|
56
42
|
HF_SCHEME = "hf"
|
57
43
|
|
58
|
-
|
44
|
+
ASSET_DIR = "assets"
|
45
|
+
TOKENIZER_ASSET_DIR = f"{ASSET_DIR}/tokenizer"
|
59
46
|
|
60
47
|
# Config file names.
|
61
48
|
CONFIG_FILE = "config.json"
|
@@ -307,13 +294,6 @@ def make_preset_dir(preset):
|
|
307
294
|
os.makedirs(preset, exist_ok=True)
|
308
295
|
|
309
296
|
|
310
|
-
def save_tokenizer_assets(tokenizer, preset):
|
311
|
-
if tokenizer:
|
312
|
-
asset_dir = os.path.join(preset, TOKENIZER_ASSET_DIR)
|
313
|
-
os.makedirs(asset_dir, exist_ok=True)
|
314
|
-
tokenizer.save_assets(asset_dir)
|
315
|
-
|
316
|
-
|
317
297
|
def save_serialized_object(
|
318
298
|
layer,
|
319
299
|
preset,
|
@@ -345,37 +325,6 @@ def save_metadata(layer, preset):
|
|
345
325
|
metadata_file.write(json.dumps(metadata, indent=4))
|
346
326
|
|
347
327
|
|
348
|
-
def _validate_tokenizer(preset):
|
349
|
-
if not check_file_exists(preset, TOKENIZER_CONFIG_FILE):
|
350
|
-
return
|
351
|
-
config_path = get_file(preset, TOKENIZER_CONFIG_FILE)
|
352
|
-
try:
|
353
|
-
with open(config_path, encoding="utf-8") as config_file:
|
354
|
-
config = json.load(config_file)
|
355
|
-
except Exception as e:
|
356
|
-
raise ValueError(
|
357
|
-
f"Tokenizer config file `{config_path}` is an invalid json file. "
|
358
|
-
f"Error message: {e}"
|
359
|
-
)
|
360
|
-
layer = keras.saving.deserialize_keras_object(config)
|
361
|
-
|
362
|
-
for asset in layer.file_assets:
|
363
|
-
asset_path = get_file(preset, os.path.join(TOKENIZER_ASSET_DIR, asset))
|
364
|
-
if not os.path.exists(asset_path):
|
365
|
-
tokenizer_asset_dir = os.path.dirname(asset_path)
|
366
|
-
raise FileNotFoundError(
|
367
|
-
f"Asset `{asset}` doesn't exist in the tokenizer asset direcotry"
|
368
|
-
f" `{tokenizer_asset_dir}`."
|
369
|
-
)
|
370
|
-
config_dir = os.path.dirname(config_path)
|
371
|
-
asset_dir = os.path.join(config_dir, TOKENIZER_ASSET_DIR)
|
372
|
-
|
373
|
-
tokenizer = get_tokenizer(layer)
|
374
|
-
if not tokenizer:
|
375
|
-
raise ValueError(f"Model or layer `{layer}` is missing tokenizer.")
|
376
|
-
tokenizer.load_assets(asset_dir)
|
377
|
-
|
378
|
-
|
379
328
|
def _validate_backbone(preset):
|
380
329
|
config_path = os.path.join(preset, CONFIG_FILE)
|
381
330
|
if not os.path.exists(config_path):
|
@@ -493,7 +442,6 @@ def upload_preset(
|
|
493
442
|
raise FileNotFoundError(f"The preset directory {preset} doesn't exist.")
|
494
443
|
|
495
444
|
_validate_backbone(preset)
|
496
|
-
_validate_tokenizer(preset)
|
497
445
|
|
498
446
|
if uri.startswith(KAGGLE_PREFIX):
|
499
447
|
if kagglehub is None:
|
@@ -657,6 +605,20 @@ class PresetLoader:
|
|
657
605
|
self.config = config
|
658
606
|
self.preset = preset
|
659
607
|
|
608
|
+
def get_backbone_kwargs(self, **kwargs):
|
609
|
+
backbone_kwargs = {}
|
610
|
+
|
611
|
+
# Forward `dtype` to backbone.
|
612
|
+
backbone_kwargs["dtype"] = kwargs.pop("dtype", None)
|
613
|
+
|
614
|
+
# Forward `height` and `width` to backbone when using `TextToImage`.
|
615
|
+
if "height" in kwargs:
|
616
|
+
backbone_kwargs["height"] = kwargs.pop("height", None)
|
617
|
+
if "width" in kwargs:
|
618
|
+
backbone_kwargs["width"] = kwargs.pop("width", None)
|
619
|
+
|
620
|
+
return backbone_kwargs, kwargs
|
621
|
+
|
660
622
|
def check_backbone_class(self):
|
661
623
|
"""Infer the backbone architecture."""
|
662
624
|
raise NotImplementedError
|
@@ -665,7 +627,7 @@ class PresetLoader:
|
|
665
627
|
"""Load the backbone model from the preset."""
|
666
628
|
raise NotImplementedError
|
667
629
|
|
668
|
-
def load_tokenizer(self, cls, **kwargs):
|
630
|
+
def load_tokenizer(self, cls, config_name=TOKENIZER_CONFIG_FILE, **kwargs):
|
669
631
|
"""Load a tokenizer layer from the preset."""
|
670
632
|
raise NotImplementedError
|
671
633
|
|
@@ -685,8 +647,7 @@ class PresetLoader:
|
|
685
647
|
"""
|
686
648
|
if "backbone" not in kwargs:
|
687
649
|
backbone_class = cls.backbone_cls
|
688
|
-
|
689
|
-
backbone_kwargs = {"dtype": kwargs.pop("dtype", None)}
|
650
|
+
backbone_kwargs, kwargs = self.get_backbone_kwargs(**kwargs)
|
690
651
|
kwargs["backbone"] = self.load_backbone(
|
691
652
|
backbone_class, load_weights, **backbone_kwargs
|
692
653
|
)
|
@@ -696,23 +657,16 @@ class PresetLoader:
|
|
696
657
|
)
|
697
658
|
return cls(**kwargs)
|
698
659
|
|
699
|
-
def load_preprocessor(
|
660
|
+
def load_preprocessor(
|
661
|
+
self, cls, config_name=PREPROCESSOR_CONFIG_FILE, **kwargs
|
662
|
+
):
|
700
663
|
"""Load a prepocessor layer from the preset.
|
701
664
|
|
702
665
|
By default, we create a preprocessor from a tokenizer with default
|
703
666
|
arguments. This allow us to support transformers checkpoints by
|
704
667
|
only converting the backbone and tokenizer.
|
705
668
|
"""
|
706
|
-
|
707
|
-
kwargs["tokenizer"] = self.load_tokenizer(cls.tokenizer_cls)
|
708
|
-
if "audio_converter" not in kwargs and cls.audio_converter_cls:
|
709
|
-
kwargs["audio_converter"] = self.load_audio_converter(
|
710
|
-
cls.audio_converter_cls
|
711
|
-
)
|
712
|
-
if "image_converter" not in kwargs and cls.image_converter_cls:
|
713
|
-
kwargs["image_converter"] = self.load_image_converter(
|
714
|
-
cls.image_converter_cls
|
715
|
-
)
|
669
|
+
kwargs = cls._add_missing_kwargs(self, kwargs)
|
716
670
|
return cls(**kwargs)
|
717
671
|
|
718
672
|
|
@@ -727,8 +681,8 @@ class KerasPresetLoader(PresetLoader):
|
|
727
681
|
backbone.load_weights(get_file(self.preset, MODEL_WEIGHTS_FILE))
|
728
682
|
return backbone
|
729
683
|
|
730
|
-
def load_tokenizer(self, cls, **kwargs):
|
731
|
-
tokenizer_config = load_json(self.preset,
|
684
|
+
def load_tokenizer(self, cls, config_name=TOKENIZER_CONFIG_FILE, **kwargs):
|
685
|
+
tokenizer_config = load_json(self.preset, config_name)
|
732
686
|
tokenizer = load_serialized_object(tokenizer_config, **kwargs)
|
733
687
|
tokenizer.load_preset_assets(self.preset)
|
734
688
|
return tokenizer
|
@@ -755,8 +709,8 @@ class KerasPresetLoader(PresetLoader):
|
|
755
709
|
)
|
756
710
|
# We found a `task.json` with a complete config for our class.
|
757
711
|
task = load_serialized_object(task_config, **kwargs)
|
758
|
-
if task.preprocessor
|
759
|
-
task.preprocessor.
|
712
|
+
if task.preprocessor:
|
713
|
+
task.preprocessor.load_preset_assets(self.preset)
|
760
714
|
if load_weights:
|
761
715
|
has_task_weights = check_file_exists(self.preset, TASK_WEIGHTS_FILE)
|
762
716
|
if has_task_weights and load_task_weights:
|
@@ -769,15 +723,17 @@ class KerasPresetLoader(PresetLoader):
|
|
769
723
|
task.backbone.load_weights(backbone_weights)
|
770
724
|
return task
|
771
725
|
|
772
|
-
def load_preprocessor(
|
726
|
+
def load_preprocessor(
|
727
|
+
self, cls, config_name=PREPROCESSOR_CONFIG_FILE, **kwargs
|
728
|
+
):
|
773
729
|
# If there is no `preprocessing.json` or it's for the wrong class,
|
774
730
|
# delegate to the super class loader.
|
775
|
-
if not check_file_exists(self.preset,
|
731
|
+
if not check_file_exists(self.preset, config_name):
|
776
732
|
return super().load_preprocessor(cls, **kwargs)
|
777
|
-
preprocessor_json = load_json(self.preset,
|
733
|
+
preprocessor_json = load_json(self.preset, config_name)
|
778
734
|
if not issubclass(check_config_class(preprocessor_json), cls):
|
779
735
|
return super().load_preprocessor(cls, **kwargs)
|
780
736
|
# We found a `preprocessing.json` with a complete config for our class.
|
781
737
|
preprocessor = load_serialized_object(preprocessor_json, **kwargs)
|
782
|
-
preprocessor.
|
738
|
+
preprocessor.load_preset_assets(self.preset)
|
783
739
|
return preprocessor
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
"""Utilities with miscellaneous python extensions."""
|
15
2
|
|
16
3
|
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
|
-
|
15
1
|
import contextlib
|
16
2
|
import functools
|
17
3
|
import inspect
|
@@ -322,3 +308,109 @@ def any_equal(inputs, values, padding_mask):
|
|
322
308
|
output = ops.logical_or(output, value_equality)
|
323
309
|
|
324
310
|
return ops.logical_and(output, padding_mask)
|
311
|
+
|
312
|
+
|
313
|
+
def target_gather(
|
314
|
+
targets,
|
315
|
+
indices,
|
316
|
+
mask=None,
|
317
|
+
mask_val=0.0,
|
318
|
+
):
|
319
|
+
"""A utility function wrapping `ops.take`, which deals with:
|
320
|
+
1) both batched and unbatched `targets`.
|
321
|
+
2) when unbatched `targets` have empty rows, the result will be filled
|
322
|
+
with `mask_val`.
|
323
|
+
3) target masking.
|
324
|
+
|
325
|
+
Args:
|
326
|
+
targets: `[N, ...]` or `[batch_size, N, ...]` Tensor representing
|
327
|
+
targets such as boxes, keypoints, etc.
|
328
|
+
indices: [M] or [batch_size, M] int32 Tensor representing indices within
|
329
|
+
`targets` to gather.
|
330
|
+
mask: `[M, ...]` or `[batch_size, M, ...]` boolean Tensor
|
331
|
+
representing the masking for each target. `True` means the
|
332
|
+
corresponding entity should be masked to `mask_val`, `False`
|
333
|
+
means the corresponding entity should be the target value.
|
334
|
+
Defaults to `None`.
|
335
|
+
mask_val: float. representing the masking value if `mask` is True
|
336
|
+
on the entity.
|
337
|
+
Defaults to `0.0`
|
338
|
+
|
339
|
+
Returns:
|
340
|
+
targets: `[M, ...]` or `[batch_size, M, ...]` Tensor representing
|
341
|
+
selected targets.
|
342
|
+
|
343
|
+
Raise:
|
344
|
+
ValueError: If `targets` is higher than rank 3.
|
345
|
+
"""
|
346
|
+
targets_shape = list(targets.shape)
|
347
|
+
if len(targets_shape) > 3:
|
348
|
+
raise ValueError(
|
349
|
+
f"`target_gather` does not support `targets` with rank "
|
350
|
+
f"larger than 3, got {len(targets.shape)}"
|
351
|
+
)
|
352
|
+
|
353
|
+
def gather_unbatched(labels, match_indices, mask, mask_val):
|
354
|
+
"""Gather based on unbatched labels and boxes."""
|
355
|
+
num_gt_boxes = labels.shape[0]
|
356
|
+
|
357
|
+
def assign_when_rows_empty():
|
358
|
+
if len(labels.shape) > 1:
|
359
|
+
mask_shape = [match_indices.shape[0], labels.shape[-1]]
|
360
|
+
else:
|
361
|
+
mask_shape = [match_indices.shape[0]]
|
362
|
+
return ops.cast(mask_val, labels.dtype) * ops.ones(
|
363
|
+
mask_shape, dtype=labels.dtype
|
364
|
+
)
|
365
|
+
|
366
|
+
def assign_when_rows_not_empty():
|
367
|
+
targets = ops.take(labels, match_indices, axis=0)
|
368
|
+
if mask is None:
|
369
|
+
return targets
|
370
|
+
else:
|
371
|
+
masked_targets = ops.cast(
|
372
|
+
mask_val, labels.dtype
|
373
|
+
) * ops.ones_like(mask, dtype=labels.dtype)
|
374
|
+
return ops.where(mask, masked_targets, targets)
|
375
|
+
|
376
|
+
if num_gt_boxes > 0:
|
377
|
+
return assign_when_rows_not_empty()
|
378
|
+
else:
|
379
|
+
return assign_when_rows_empty()
|
380
|
+
|
381
|
+
def _gather_batched(labels, match_indices, mask, mask_val):
|
382
|
+
"""Gather based on batched labels."""
|
383
|
+
batch_size = labels.shape[0]
|
384
|
+
if batch_size == 1:
|
385
|
+
if mask is not None:
|
386
|
+
result = gather_unbatched(
|
387
|
+
ops.squeeze(labels, axis=0),
|
388
|
+
ops.squeeze(match_indices, axis=0),
|
389
|
+
ops.squeeze(mask, axis=0),
|
390
|
+
mask_val,
|
391
|
+
)
|
392
|
+
else:
|
393
|
+
result = gather_unbatched(
|
394
|
+
ops.squeeze(labels, axis=0),
|
395
|
+
ops.squeeze(match_indices, axis=0),
|
396
|
+
None,
|
397
|
+
mask_val,
|
398
|
+
)
|
399
|
+
return ops.expand_dims(result, axis=0)
|
400
|
+
else:
|
401
|
+
targets = ops.take_along_axis(
|
402
|
+
labels, ops.expand_dims(match_indices, axis=-1), axis=1
|
403
|
+
)
|
404
|
+
|
405
|
+
if mask is None:
|
406
|
+
return targets
|
407
|
+
else:
|
408
|
+
masked_targets = ops.cast(
|
409
|
+
mask_val, labels.dtype
|
410
|
+
) * ops.ones_like(mask, dtype=labels.dtype)
|
411
|
+
return ops.where(mask, masked_targets, targets)
|
412
|
+
|
413
|
+
if len(targets_shape) <= 2:
|
414
|
+
return gather_unbatched(targets, indices, mask, mask_val)
|
415
|
+
elif len(targets_shape) == 3:
|
416
|
+
return _gather_batched(targets, indices, mask, mask_val)
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHUB 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.densenet.densenet_backbone import DenseNetBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.resnet.resnet_backbone import ResNetBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
"""Convert timm models to KerasHub."""
|
15
2
|
|
16
3
|
from keras_hub.src.models.image_classifier import ImageClassifier
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.albert.albert_backbone import AlbertBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.bart.bart_backbone import BartBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.bert.bert_backbone import BertBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.distil_bert.distil_bert_backbone import (
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.gemma.gemma_backbone import GemmaBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.gpt2.gpt2_backbone import GPT2Backbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.llama3.llama3_backbone import Llama3Backbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.mistral.mistral_backbone import MistralBackbone
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import numpy as np
|
15
2
|
|
16
3
|
from keras_hub.src.models.pali_gemma.pali_gemma_backbone import (
|
@@ -1,19 +1,5 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
"""Convert huggingface models to KerasHub."""
|
15
2
|
|
16
|
-
|
17
3
|
from keras_hub.src.utils.preset_utils import PresetLoader
|
18
4
|
from keras_hub.src.utils.preset_utils import jax_memory_cleanup
|
19
5
|
from keras_hub.src.utils.transformers import convert_albert
|
@@ -69,7 +55,7 @@ class TransformersPresetLoader(PresetLoader):
|
|
69
55
|
self.converter.convert_weights(backbone, loader, self.config)
|
70
56
|
return backbone
|
71
57
|
|
72
|
-
def load_tokenizer(self, cls, **kwargs):
|
58
|
+
def load_tokenizer(self, cls, config_name="tokenizer.json", **kwargs):
|
73
59
|
return self.converter.convert_tokenizer(cls, self.preset, **kwargs)
|
74
60
|
|
75
61
|
def load_image_converter(self, cls, **kwargs):
|
@@ -1,16 +1,3 @@
|
|
1
|
-
# Copyright 2024 The KerasHub 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.
|
14
1
|
import contextlib
|
15
2
|
|
16
3
|
from keras_hub.src.utils.preset_utils import SAFETENSOR_CONFIG_FILE
|
@@ -26,7 +13,7 @@ except ImportError:
|
|
26
13
|
|
27
14
|
|
28
15
|
class SafetensorLoader(contextlib.ExitStack):
|
29
|
-
def __init__(self, preset, prefix=None):
|
16
|
+
def __init__(self, preset, prefix=None, fname=None):
|
30
17
|
super().__init__()
|
31
18
|
|
32
19
|
if safetensors is None:
|
@@ -44,6 +31,13 @@ class SafetensorLoader(contextlib.ExitStack):
|
|
44
31
|
self.safetensor_files = {}
|
45
32
|
self.prefix = prefix
|
46
33
|
|
34
|
+
if fname is not None and self.safetensor_config is not None:
|
35
|
+
raise ValueError(
|
36
|
+
f"Cannot specify `fname` if {SAFETENSOR_CONFIG_FILE} exists. "
|
37
|
+
f"Received: fname={fname}"
|
38
|
+
)
|
39
|
+
self.fname = fname # Specify the name of the safetensor file.
|
40
|
+
|
47
41
|
def get_prefixed_key(self, hf_weight_key, dict_like):
|
48
42
|
"""
|
49
43
|
Determine and return a prefixed key for a given hf weight key.
|
@@ -71,7 +65,7 @@ class SafetensorLoader(contextlib.ExitStack):
|
|
71
65
|
|
72
66
|
def get_tensor(self, hf_weight_key):
|
73
67
|
if self.safetensor_config is None:
|
74
|
-
fname = SAFETENSOR_FILE
|
68
|
+
fname = self.fname if self.fname is not None else SAFETENSOR_FILE
|
75
69
|
else:
|
76
70
|
full_key = self.get_prefixed_key(
|
77
71
|
hf_weight_key, self.safetensor_config["weight_map"]
|