Image Classification
KerasHub
Divyasreepat commited on
Commit
97be9f4
1 Parent(s): 5825f18

Update README.md with new model card content

Browse files
Files changed (1) hide show
  1. README.md +90 -16
README.md CHANGED
@@ -1,19 +1,93 @@
1
  ---
2
  library_name: keras-hub
3
  ---
4
- This is a [`ResNet` model](https://keras.io/api/keras_hub/models/res_net) uploaded using the KerasHub library and can be used with JAX, TensorFlow, and PyTorch backends.
5
- This model is related to a `ImageClassifier` task.
6
-
7
- Model config:
8
- * **name:** res_net_backbone
9
- * **trainable:** True
10
- * **input_conv_filters:** [64]
11
- * **input_conv_kernel_sizes:** [7]
12
- * **stackwise_num_filters:** [64, 128, 256, 512]
13
- * **stackwise_num_blocks:** [3, 4, 6, 3]
14
- * **stackwise_num_strides:** [1, 2, 2, 2]
15
- * **block_type:** bottleneck_block
16
- * **use_pre_activation:** False
17
- * **image_shape:** [None, None, 3]
18
-
19
- This model card has been generated automatically and should be completed by the model author. See [Model Cards documentation](https://huggingface.co/docs/hub/model-cards) for more information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  library_name: keras-hub
3
  ---
4
+ ### Model Overview
5
+ Instantiates the ResNet architecture. This model is supported in both KerasCV and KerasHub. KerasCV will no longer be actively developed, so please try to use KerasHub.
6
+
7
+ **Reference**
8
+
9
+ - [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385)
10
+
11
+ The difference in ResNetV1 and ResNetV2 rests in the structure of their
12
+ individual building blocks. In ResNetV2, the batch normalization and
13
+ ReLU activation precede the convolution layers, as opposed to ResNetV1 where
14
+ the batch normalization and ReLU activation are applied after the
15
+ convolution layers.
16
+
17
+ ## Links
18
+
19
+ coming soon
20
+
21
+
22
+ ## Installation
23
+
24
+ Keras and KerasHub can be installed with:
25
+
26
+ ```
27
+ pip install -U -q keras-hub
28
+ pip install -U -q keras
29
+ ```
30
+
31
+ Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the [Keras Getting Started](https://keras.io/getting_started/) page.
32
+
33
+ ## Presets
34
+
35
+ The following model checkpoints are provided by the Keras team. Weights have been ported from: https://huggingface.co/timm. Full code examples for each are available below.
36
+
37
+ | Preset name | Parameters | Description |
38
+ |------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
39
+ | resnet_18_imagenet | 11.19M | 18-layer ResNet model pre-trained on the ImageNet 1k dataset at a 224x224 resolution |
40
+ | resnet_50_imagenet | 23.56M | 50-layer ResNet model pre-trained on the ImageNet 1k dataset at a 224x224 resolution |
41
+ | resnet_101_imagenet | 42.61M | 101-layer ResNet model pre-trained on the ImageNet 1k dataset at a 224x224 resolution |
42
+ | resnet_152_imagenet | 58.30M | 52-layer ResNet model pre-trained on the ImageNet 1k dataset at a 224x224 resolution |
43
+
44
+ ### Example Usage
45
+ ```python
46
+ # Pretrained ResNet backbone.
47
+ model = keras_hub.models.ResNetBackbone.from_preset("resnet_101_imagenet")
48
+ input_data = np.random.uniform(0, 1, size=(2, 224, 224, 3))
49
+ model(input_data)
50
+
51
+ # Randomly initialized ResNetV2 backbone with a custom config.
52
+ model = keras_hub.models.ResNetBackbone(
53
+ input_conv_filters=[64],
54
+ input_conv_kernel_sizes=[7],
55
+ stackwise_num_filters=[64, 64, 64],
56
+ stackwise_num_blocks=[2, 2, 2],
57
+ stackwise_num_strides=[1, 2, 2],
58
+ block_type="basic_block",
59
+ use_pre_activation=True,
60
+ )
61
+ model(input_data)
62
+ # Use resnet for image classification task
63
+ model = keras_hub.models.ImageClassifier.from_preset("resnet_101_imagenet")
64
+
65
+ # User timm presets directly from hugingface
66
+ model = keras_hub.models.ImageClassifier.from_preset('hf://timm/resnet101.a1_in1k')
67
+ ```
68
+
69
+ ## Example Usage with Hugging Face URI
70
+
71
+ ```python
72
+ # Pretrained ResNet backbone.
73
+ model = keras_hub.models.ResNetBackbone.from_preset("resnet_101_imagenet")
74
+ input_data = np.random.uniform(0, 1, size=(2, 224, 224, 3))
75
+ model(input_data)
76
+
77
+ # Randomly initialized ResNetV2 backbone with a custom config.
78
+ model = keras_hub.models.ResNetBackbone(
79
+ input_conv_filters=[64],
80
+ input_conv_kernel_sizes=[7],
81
+ stackwise_num_filters=[64, 64, 64],
82
+ stackwise_num_blocks=[2, 2, 2],
83
+ stackwise_num_strides=[1, 2, 2],
84
+ block_type="basic_block",
85
+ use_pre_activation=True,
86
+ )
87
+ model(input_data)
88
+ # Use resnet for image classification task
89
+ model = keras_hub.models.ImageClassifier.from_preset("resnet_101_imagenet")
90
+
91
+ # User timm presets directly from hugingface
92
+ model = keras_hub.models.ImageClassifier.from_preset('hf://timm/resnet101.a1_in1k')
93
+ ```