Divyasreepat
commited on
Commit
•
310f762
1
Parent(s):
f265b5c
Update README.md with new model card content
Browse files
README.md
CHANGED
@@ -1,19 +1,93 @@
|
|
1 |
---
|
2 |
library_name: keras-hub
|
3 |
---
|
4 |
-
|
5 |
-
This model is
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
```
|