All from scratch #71
leondgarse
started this conversation in
Show and tell
Replies: 2 comments
-
Basic ImplementationIntroduce
Default import
Loading data by ImageDataGenerator
Convert ImageDataGenerator to dataset
Basic model
Softmax loss train
Arcface loss train
Combined train
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Advanced ImplementationIntroduce
Default import
Loading data by Datasets
Evaluation callback
Callbacks
Softmax loss trainfrom tensorflow import keras
''' Build model '''
xx = tf.keras.applications.MobileNetV2(input_shape=(112, 112, 3), include_top=False, weights='imagenet')
xx.trainable = True
inputs = xx.inputs[0]
nn = xx.outputs[0]
nn = keras.layers.GlobalAveragePooling2D()(nn)
# nn = keras.layers.Dropout(0.1)(nn)
embedding = keras.layers.Dense(512, name='embedding')(nn)
basic_model = keras.models.Model(inputs, embedding)
output = keras.layers.Dense(classes, activation='softmax')(basic_model.outputs[0])
model = keras.models.Model(basic_model.inputs[0], output)
# model.summary()
model.compile(optimizer='adamax', loss=keras.losses.CategoricalCrossentropy(label_smoothing=0.1), metrics="acc")
hist = model.fit(train_ds, epochs=20, verbose=1, callbacks=callbacks, steps_per_epoch=steps_per_epoch, initial_epoch=0) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beforehand Data Prepare
Data source from Insightface
MS1M-ArcFace
downloaded from Insightface Dataset ZooLFW
CFP-FP
AgeDB-30
bin files included inMS1M-ArcFace
datasetTraining dataset
. ├── 0 │ ├── 100.jpg │ ├── 101.jpg │ └── 102.jpg ├── 1 │ ├── 111.jpg │ ├── 112.jpg │ └── 113.jpg ├── 10 │ ├── 707.jpg │ ├── 708.jpg │ └── 709.jpg
/datasets/faces_emore
, extract to dist folder/datasets/faces_emore_112x112_folders
, this may take some time.Evaluating bin files
CFP-FP
AgeDB-30
is not compatible withtf.image.decode_jpeg
, we need to reformat it.Conclusion
Beta Was this translation helpful? Give feedback.
All reactions