mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-03-12 20:42:45 -07:00
51 lines
2.2 KiB
Python
51 lines
2.2 KiB
Python
from nnlib import nnlib
|
|
|
|
def VGGFace():
|
|
exec(nnlib.import_all(), locals(), globals())
|
|
|
|
img_input = Input(shape=(224,224,3) )
|
|
|
|
# Block 1
|
|
x = Conv2D(64, (3, 3), activation='relu', padding='same', name='conv1_1')(img_input)
|
|
x = Conv2D(64, (3, 3), activation='relu', padding='same', name='conv1_2')(x)
|
|
x = MaxPooling2D((2, 2), strides=(2, 2), name='pool1')(x)
|
|
|
|
# Block 2
|
|
x = Conv2D(128, (3, 3), activation='relu', padding='same', name='conv2_1')(x)
|
|
x = Conv2D(128, (3, 3), activation='relu', padding='same', name='conv2_2')(x)
|
|
x = MaxPooling2D((2, 2), strides=(2, 2), name='pool2')(x)
|
|
|
|
# Block 3
|
|
x = Conv2D(256, (3, 3), activation='relu', padding='same', name='conv3_1')(x)
|
|
x = Conv2D(256, (3, 3), activation='relu', padding='same', name='conv3_2')(x)
|
|
x = Conv2D(256, (3, 3), activation='relu', padding='same', name='conv3_3')(x)
|
|
x = MaxPooling2D((2, 2), strides=(2, 2), name='pool3')(x)
|
|
|
|
# Block 4
|
|
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='conv4_1')(x)
|
|
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='conv4_2')(x)
|
|
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='conv4_3')(x)
|
|
x = MaxPooling2D((2, 2), strides=(2, 2), name='pool4')(x)
|
|
|
|
# Block 5
|
|
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='conv5_1')(x)
|
|
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='conv5_2')(x)
|
|
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='conv5_3')(x)
|
|
x = MaxPooling2D((2, 2), strides=(2, 2), name='pool5')(x)
|
|
|
|
|
|
# Classification block
|
|
x = Flatten(name='flatten')(x)
|
|
x = Dense(4096, name='fc6')(x)
|
|
x = Activation('relu', name='fc6/relu')(x)
|
|
x = Dense(4096, name='fc7')(x)
|
|
x = Activation('relu', name='fc7/relu')(x)
|
|
x = Dense(2622, name='fc8')(x)
|
|
x = Activation('softmax', name='fc8/softmax')(x)
|
|
|
|
model = Model(img_input, x, name='vggface_vgg16')
|
|
weights_path = keras.utils.data_utils.get_file('rcmalli_vggface_tf_vgg16.h5',
|
|
'https://github.com/rcmalli/keras-vggface/releases/download/v2.0/rcmalli_vggface_tf_vgg16.h5')
|
|
model.load_weights(weights_path, by_name=True)
|
|
|
|
return model |