0
# Pre-trained Models
1
2
Extensive collection of pre-trained computer vision models with ImageNet weights for transfer learning, feature extraction, and fine-tuning across various architectures including ResNet, EfficientNet, VGG, MobileNet, and Inception families.
3
4
## Capabilities
5
6
### ResNet Models
7
8
Residual networks with skip connections for deep architectures.
9
10
```python { .api }
11
def ResNet50(include_top=True, weights='imagenet', input_tensor=None, input_shape=None,
12
pooling=None, classes=1000, classifier_activation='softmax', **kwargs):
13
"""
14
ResNet50 architecture.
15
16
Args:
17
include_top (bool): Whether to include classification head
18
weights (str): Pre-trained weights ('imagenet' or None)
19
input_tensor: Optional input tensor
20
input_shape (tuple): Input shape for images
21
pooling (str): Pooling mode ('avg', 'max', or None)
22
classes (int): Number of classes for classification
23
classifier_activation (str): Activation for final layer
24
25
Returns:
26
Model: ResNet50 model
27
"""
28
29
def ResNet101(include_top=True, weights='imagenet', **kwargs): ...
30
def ResNet152(include_top=True, weights='imagenet', **kwargs): ...
31
def ResNet50V2(include_top=True, weights='imagenet', **kwargs): ...
32
def ResNet101V2(include_top=True, weights='imagenet', **kwargs): ...
33
def ResNet152V2(include_top=True, weights='imagenet', **kwargs): ...
34
```
35
36
### EfficientNet Models
37
38
Compound scaled convolutional networks optimized for efficiency and accuracy.
39
40
```python { .api }
41
def EfficientNetB0(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
42
def EfficientNetB1(include_top=True, weights='imagenet', **kwargs): ...
43
def EfficientNetB2(include_top=True, weights='imagenet', **kwargs): ...
44
def EfficientNetB3(include_top=True, weights='imagenet', **kwargs): ...
45
def EfficientNetB4(include_top=True, weights='imagenet', **kwargs): ...
46
def EfficientNetB5(include_top=True, weights='imagenet', **kwargs): ...
47
def EfficientNetB6(include_top=True, weights='imagenet', **kwargs): ...
48
def EfficientNetB7(include_top=True, weights='imagenet', **kwargs): ...
49
50
def EfficientNetV2B0(include_top=True, weights='imagenet', **kwargs): ...
51
def EfficientNetV2B1(include_top=True, weights='imagenet', **kwargs): ...
52
def EfficientNetV2B2(include_top=True, weights='imagenet', **kwargs): ...
53
def EfficientNetV2B3(include_top=True, weights='imagenet', **kwargs): ...
54
def EfficientNetV2S(include_top=True, weights='imagenet', **kwargs): ...
55
def EfficientNetV2M(include_top=True, weights='imagenet', **kwargs): ...
56
def EfficientNetV2L(include_top=True, weights='imagenet', **kwargs): ...
57
```
58
59
### VGG Models
60
61
Visual Geometry Group architectures with small convolution filters.
62
63
```python { .api }
64
def VGG16(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
65
def VGG19(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
66
```
67
68
### MobileNet Models
69
70
Lightweight models optimized for mobile and embedded devices.
71
72
```python { .api }
73
def MobileNet(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
74
def MobileNetV2(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
75
def MobileNetV3Small(include_top=True, weights='imagenet', **kwargs): ...
76
def MobileNetV3Large(include_top=True, weights='imagenet', **kwargs): ...
77
```
78
79
### Other Architectures
80
81
```python { .api }
82
def InceptionV3(include_top=True, weights='imagenet', **kwargs): ...
83
def InceptionResNetV2(include_top=True, weights='imagenet', **kwargs): ...
84
def Xception(include_top=True, weights='imagenet', **kwargs): ...
85
def DenseNet121(include_top=True, weights='imagenet', **kwargs): ...
86
def DenseNet169(include_top=True, weights='imagenet', **kwargs): ...
87
def DenseNet201(include_top=True, weights='imagenet', **kwargs): ...
88
def NASNetMobile(include_top=True, weights='imagenet', **kwargs): ...
89
def NASNetLarge(include_top=True, weights='imagenet', **kwargs): ...
90
```
91
92
## Usage Examples
93
94
### Transfer Learning
95
96
```python
97
import keras
98
from keras.applications import ResNet50
99
from keras import layers
100
101
# Load pre-trained model without top classification layer
102
base_model = ResNet50(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
103
104
# Freeze base model weights
105
base_model.trainable = False
106
107
# Add custom classification head
108
model = keras.Sequential([
109
base_model,
110
layers.GlobalAveragePooling2D(),
111
layers.Dense(128, activation='relu'),
112
layers.Dropout(0.2),
113
layers.Dense(num_classes, activation='softmax')
114
])
115
116
model.compile(
117
optimizer='adam',
118
loss='sparse_categorical_crossentropy',
119
metrics=['accuracy']
120
)
121
```
122
123
### Feature Extraction
124
125
```python
126
from keras.applications import EfficientNetB0
127
from keras.applications.efficientnet import preprocess_input
128
129
# Load model for feature extraction
130
model = EfficientNetB0(weights='imagenet', include_top=False, pooling='avg')
131
132
# Preprocess images
133
x = preprocess_input(images)
134
135
# Extract features
136
features = model.predict(x)
137
```