keras-team / keras-hub

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

Take two of #1812, simpler classifier head loading #1823

Closed mattdangerw closed 2 months ago

mattdangerw commented 2 months ago

Let's get rid of load_task_extras, which is a bad and confusing name. Instead, we will adopt some behavior that is specific to classifiers, but a lot simpler.

# Random head.
classifier = ImageClassifier.from_preset("resnet50", num_classes=2)
# Pretrained head.
classifier = ImageClassifier.from_preset("resnet50")
# Error, must provide num_classes.
classifier = TextClassifier.from_preset("bert_base_en")