keras-team / keras-hub

Pretrained model hub for Keras 3
Apache License 2.0
804 stars 243 forks source link

Two fixes for image resizing in preprocessing #1927

Closed mattdangerw closed 1 month ago

mattdangerw commented 1 month ago
  1. Properly display when are not resizing the input image in model.summary()
  2. Allow setting the image_size directly on a preprocessing layer.

2. is just to allow a more consistent way to set the input shape across tasks. We now have:

text_classifier = keras_hub.models.TextClassifer.from_preset(
    "bert_base_en",
)
text_classifier.preprocessor.sequence_length = 256

image_classifier = keras_hub.models.TextClassifer.from_preset(
    "bert_base_en",
)
image_classifier.preprocessor.image_size = (256, 256)

multi_modal_lm = keras_hub.models.CausalLM.from_preset(
    "some_preset",
)
multi_modal_lm.preprocessor.sequence_length = 256
multi_modal_lm.preprocessor.image_size = (256, 256)