keras-team / keras-hub

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

Add `ResNetBackbone` and `ResNetImageClassifier` #1765

Closed james77777778 closed 3 months ago

james77777778 commented 3 months ago

Closes #1750

This PR largely follows #1737 but introduces some improvements:

The preact parameter in ResNetBackbone determines whether to instantiate ResNet or ResNetV2 (similar to keras.applications.ResNet*) https://github.com/keras-team/keras/blob/b45be337c6156d90f220beba9f68eeb2e52e2b0d/keras/src/applications/resnet.py#L50

I have a small question regarding model implementation: When creating a Dense layer in ImageClassifier, the dtype_policy is not configurable. I used backbone.dtype_policy as a workaround but it might be fragile.

The implementation has been verified by using the model weights from KerasCV. Please refer to this colab: https://colab.research.google.com/drive/1HGktF-4TkTdTjlMVv7qr3D_ysspJXDmo?usp=sharing

@mattdangerw @divyashreepathihalli @SamanehSaadat

james77777778 commented 3 months ago

@divyashreepathihalli @mattdangerw Thanks for reviewing. All comments should be resolved.

But my question still remains:

When creating a Dense layer in ImageClassifier, the dtype_policy is not configurable.

Any ideas about that?

james77777778 commented 3 months ago

Another question: Should we support pyramid feature outputs in vision backbones? This is crucial for any downstream algorithms (object detection, segmentation, ...)

https://github.com/keras-team/keras-cv/blob/5cfe7c3d8f2d758b91bbfcedf7f0a29931236c68/keras_cv/src/models/backbones/backbone.py#L153-L176

divyashreepathihalli commented 3 months ago

Another question: Should we support pyramid feature outputs in vision backbones? This is crucial for any downstream algorithms (object detection, segmentation, ...)

https://github.com/keras-team/keras-cv/blob/5cfe7c3d8f2d758b91bbfcedf7f0a29931236c68/keras_cv/src/models/backbones/backbone.py#L153-L176

This sounds like a good idea! Lets add it in new PR