From 20af77e41f7eaef71360d96a9a6222aba5478efd Mon Sep 17 00:00:00 2001 From: myname Date: Fri, 24 Jun 2022 19:42:37 +0700 Subject: [PATCH 1/2] Fix eval --- config/config_DartFaceNet.py | 60 ------------------------------- config/config_PocketNetM128.py | 64 --------------------------------- config/config_PocketNetM256.py | 64 --------------------------------- config/config_PocketNetS128.py | 62 -------------------------------- config/config_PocketNetS256.py | 64 --------------------------------- config/config_example.py | 66 ---------------------------------- eval/eval.py | 6 ++-- 7 files changed, 3 insertions(+), 383 deletions(-) delete mode 100644 config/config_DartFaceNet.py delete mode 100644 config/config_PocketNetM128.py delete mode 100644 config/config_PocketNetM256.py delete mode 100644 config/config_PocketNetS128.py delete mode 100644 config/config_PocketNetS256.py delete mode 100644 config/config_example.py diff --git a/config/config_DartFaceNet.py b/config/config_DartFaceNet.py deleted file mode 100644 index 4a06818..0000000 --- a/config/config_DartFaceNet.py +++ /dev/null @@ -1,60 +0,0 @@ -from easydict import EasyDict as edict - -config = edict() -config.dataset = "emoreKD" -config.embedding_size = 128 -config.momentum = 0.9 -config.weight_decay = 5e-4 -config.batch_size = 128 -config.lr = 0.1 -config.output = "outputKD/DartFaceNet" -config.scale=1.0 -config.global_step=0 -config.s=64.0 -config.m=0.5 -config.test_output="eval" - -config.genotypes = dict({ - "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", - "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) - -# for KD -config.teacher_pth = "/home/fboutros/DartFaceNet/outputKD/iresnet512" -config.teacher_global_step = 295672 -config.network="resnet" -# if use pretrained model (not for resume!) -config.student_pth = "" -config.student_global_step = 0 -config.net_name="DartFaceNet" -config.channel = 16 -config.n_layers = 18 - - -config.w=100 - -if config.dataset == "emoreKD": - config.rec = "data/faces_emore" - config.num_classes = 85742 - config.num_image = 5822653 - config.num_epoch = 26 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - config.eval_step = 5686 - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( - [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) - config.lr_func = lr_step_func - -elif config.dataset == "webface": - config.rec = "data/faces_webface_112x112" - config.num_classes = 10572 - config.num_image = 501195 - config.num_epoch = 34 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "agedb_30"] - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( - [m for m in [20, 28, 32] if m - 1 <= epoch]) - config.lr_func = lr_step_func diff --git a/config/config_PocketNetM128.py b/config/config_PocketNetM128.py deleted file mode 100644 index b576d95..0000000 --- a/config/config_PocketNetM128.py +++ /dev/null @@ -1,64 +0,0 @@ -from easydict import EasyDict as edict - -config = edict() -config.dataset = "emoreKD" -config.embedding_size = 128 -config.momentum = 0.9 -config.weight_decay = 5e-4 -config.batch_size = 128 -config.lr = 0.1 -config.output = "output/PocketNetM-128" -config.scale=1.0 -config.global_step=0 -config.s=64.0 -config.m=0.5 -config.test_output="eval" - -config.genotypes = dict({ - "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", - "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) - -# for KD -config.teacher_pth = "output/iresnet128" -config.teacher_global_step = 295672 -config.teacher_network="resnet" - -# if use pretrained model (not for resume!) -config.student_pth = "" -config.student_global_step = 0 -config.net_name="PocketNetM" -if (config.net_name=="PocketNetS"): - config.channel=16 - config.n_layers=18 -elif (config.net_name=="PocketNetM"): - config.channel = 32 - config.n_layers = 9 - -config.w=100 - -if config.dataset == "emoreKD": - config.rec = "data/faces_emore" - config.num_classes = 85742 - config.num_image = 5822653 - config.num_epoch = 26 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - config.eval_step = 5686 - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( - [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) - config.lr_func = lr_step_func - -elif config.dataset == "webface": - config.rec = "data/faces_webface_112x112" - config.num_classes = 10572 - config.num_image = 501195 - config.num_epoch = 34 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( - [m for m in [20, 28, 32] if m - 1 <= epoch]) - config.lr_func = lr_step_func diff --git a/config/config_PocketNetM256.py b/config/config_PocketNetM256.py deleted file mode 100644 index b50541c..0000000 --- a/config/config_PocketNetM256.py +++ /dev/null @@ -1,64 +0,0 @@ -from easydict import EasyDict as edict - -config = edict() -config.dataset = "emoreKD" -config.embedding_size = 256 -config.momentum = 0.9 -config.weight_decay = 5e-4 -config.batch_size = 128 -config.lr = 0.1 -config.output = "output/PocketNetM-256" -config.scale=1.0 -config.global_step=0 -config.s=64.0 -config.m=0.5 -config.test_output="eval" - -config.genotypes = dict({ - "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", - "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) - -# for KD -config.teacher_pth = "output/iresnet256" -config.teacher_global_step = 295672 -config.teacher_network="resnet" - -# if use pretrained model (not for resume!) -config.student_pth = "" -config.student_global_step = 0 -config.net_name="PocketNetM" -if (config.net_name=="PocketNetS"): - config.channel=16 - config.n_layers=18 -elif (config.net_name=="PocketNetM"): - config.channel = 32 - config.n_layers = 9 - -config.w=100 - -if config.dataset == "emoreKD": - config.rec = "data/faces_emore" - config.num_classes = 85742 - config.num_image = 5822653 - config.num_epoch = 26 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - config.eval_step = 5686 - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( - [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) - config.lr_func = lr_step_func - -elif config.dataset == "webface": - config.rec = "data/faces_webface_112x112" - config.num_classes = 10572 - config.num_image = 501195 - config.num_epoch = 34 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( - [m for m in [20, 28, 32] if m - 1 <= epoch]) - config.lr_func = lr_step_func diff --git a/config/config_PocketNetS128.py b/config/config_PocketNetS128.py deleted file mode 100644 index 621d836..0000000 --- a/config/config_PocketNetS128.py +++ /dev/null @@ -1,62 +0,0 @@ -from easydict import EasyDict as edict - -config = edict() -config.dataset = "emoreKD" -config.embedding_size = 128 -config.momentum = 0.9 -config.weight_decay = 5e-4 -config.batch_size = 128 -config.lr = 0.1 -config.output = "output/PocketNetS-128" -config.scale=1.0 -config.global_step=0 -config.s=64.0 -config.m=0.5 -config.test_output="eval" - -config.genotypes = dict({ - "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", - "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) - -# for KD -config.teacher_pth = "output/iresnet128" -config.teacher_global_step = 295672 -# if use pretrained model (not for resume!) -config.student_pth = "" -config.student_global_step = 0 -config.net_name="PocketNetS" -if (config.net_name=="PocketNetS"): - config.channel=16 - config.n_layers=18 -elif (config.net_name=="PocketNetM"): - config.channel = 32 - config.n_layers = 9 - -config.w=100 - -if config.dataset == "emoreKD": - config.rec = "data/faces_emore" - config.num_classes = 85742 - config.num_image = 5822653 - config.num_epoch = 26 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - config.eval_step = 5686 - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( - [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) - config.lr_func = lr_step_func - -elif config.dataset == "webface": - config.rec = "data/faces_webface_112x112" - config.num_classes = 10572 - config.num_image = 501195 - config.num_epoch = 34 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( - [m for m in [20, 28, 32] if m - 1 <= epoch]) - config.lr_func = lr_step_func diff --git a/config/config_PocketNetS256.py b/config/config_PocketNetS256.py deleted file mode 100644 index 565925e..0000000 --- a/config/config_PocketNetS256.py +++ /dev/null @@ -1,64 +0,0 @@ -from easydict import EasyDict as edict - -config = edict() -config.dataset = "emoreKD" -config.embedding_size = 256 -config.momentum = 0.9 -config.weight_decay = 5e-4 -config.batch_size = 128 -config.lr = 0.1 -config.output = "output/PocketNetS-256" -config.scale=1.0 -config.global_step=0 -config.s=64.0 -config.m=0.5 - -config.genotypes = dict({ - "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", - "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) - - -config.test_output="eval" - -# for KD -config.teacher_pth = "output/iresnet256" -config.teacher_global_step = 295672 -# if use pretrained model (not for resume!) -config.student_pth = "" -config.student_global_step = 0 -config.net_name="PocketNetS" -if (config.net_name=="PocketNetS"): - config.channel=16 - config.n_layers=18 -elif (config.net_name=="PocketNetM"): - config.channel = 32 - config.n_layers = 9 - -config.w=100 - -if config.dataset == "emoreKD": - config.rec = "data/faces_emore" - config.num_classes = 85742 - config.num_image = 5822653 - config.num_epoch = 26 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - config.eval_step = 5686 - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( - [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) - config.lr_func = lr_step_func - -elif config.dataset == "webface": - config.rec = "data/faces_webface_112x112" - config.num_classes = 10572 - config.num_image = 501195 - config.num_epoch = 34 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( - [m for m in [20, 28, 32] if m - 1 <= epoch]) - config.lr_func = lr_step_func diff --git a/config/config_example.py b/config/config_example.py deleted file mode 100644 index e324889..0000000 --- a/config/config_example.py +++ /dev/null @@ -1,66 +0,0 @@ -from easydict import EasyDict as edict - -config = edict() -config.dataset = "emoreKD" -config.embedding_size = 128 -config.momentum = 0.9 -config.weight_decay = 5e-4 -config.batch_size = 128 -config.lr = 0.1 -config.output = "output/PocketNetM-128" -config.scale=1.0 -config.global_step=0 -config.s=64.0 -config.m=0.5 - - -config.test_output="eval" - -config.genotypes = dict({ - "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", - "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) - -# for KD -config.teacher_pth = "output/iresnet128" -config.teacher_global_step = 295672 -config.teacher_network="resnet" - -# if use pretrained model (not for resume!) -config.student_pth = "" -config.student_global_step = 0 -config.net_name="PocketNetM" -if (config.net_name=="PocketNetS"): - config.channel=16 - config.n_layers=18 -elif (config.net_name=="PocketNetM"): - config.channel = 32 - config.n_layers = 9 - -config.w=100 - -if config.dataset == "emoreKD": - config.rec = "data/faces_emore" - config.num_classes = 85742 - config.num_image = 5822653 - config.num_epoch = 26 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - config.eval_step = 5686 - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( - [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) - config.lr_func = lr_step_func - -elif config.dataset == "webface": - config.rec = "data/faces_webface_112x112" - config.num_classes = 10572 - config.num_image = 501195 - config.num_epoch = 34 - config.warmup_epoch = -1 - config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] - - def lr_step_func(epoch): - return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( - [m for m in [20, 28, 32] if m - 1 <= epoch]) - config.lr_func = lr_step_func diff --git a/eval/eval.py b/eval/eval.py index beddea8..c4fef4d 100644 --- a/eval/eval.py +++ b/eval/eval.py @@ -12,14 +12,14 @@ from utils.utils_callbacks import CallBackVerification from utils.utils_logging import init_logging -from util.config import config as cfg +from configs.config_PocketNetS128 import config as cfg if __name__ == "__main__": gpu_id = 0 log_root = logging.getLogger() - if not (os.path.isdir(cfg.test_output)): - os.makedirs(cfg.test_output) + if not (os.path.isdir(cfg.output)): + os.makedirs(cfg.output) init_logging(log_root, 0, cfg.test_output,logfile="test.log") callback_verification = CallBackVerification(1, 0, cfg.val_targets, cfg.rec) output_folder=cfg.output From 0a24e56c96da45a7d6f97d18294531f876724634 Mon Sep 17 00:00:00 2001 From: myname Date: Fri, 24 Jun 2022 19:48:25 +0700 Subject: [PATCH 2/2] Add configs --- configs/config_DartFaceNet.py | 60 ++++++++++++++++++++++++++++++ configs/config_PocketNetM128.py | 64 ++++++++++++++++++++++++++++++++ configs/config_PocketNetM256.py | 64 ++++++++++++++++++++++++++++++++ configs/config_PocketNetS128.py | 62 +++++++++++++++++++++++++++++++ configs/config_PocketNetS256.py | 64 ++++++++++++++++++++++++++++++++ configs/config_example.py | 66 +++++++++++++++++++++++++++++++++ 6 files changed, 380 insertions(+) create mode 100644 configs/config_DartFaceNet.py create mode 100644 configs/config_PocketNetM128.py create mode 100644 configs/config_PocketNetM256.py create mode 100644 configs/config_PocketNetS128.py create mode 100644 configs/config_PocketNetS256.py create mode 100644 configs/config_example.py diff --git a/configs/config_DartFaceNet.py b/configs/config_DartFaceNet.py new file mode 100644 index 0000000..4a06818 --- /dev/null +++ b/configs/config_DartFaceNet.py @@ -0,0 +1,60 @@ +from easydict import EasyDict as edict + +config = edict() +config.dataset = "emoreKD" +config.embedding_size = 128 +config.momentum = 0.9 +config.weight_decay = 5e-4 +config.batch_size = 128 +config.lr = 0.1 +config.output = "outputKD/DartFaceNet" +config.scale=1.0 +config.global_step=0 +config.s=64.0 +config.m=0.5 +config.test_output="eval" + +config.genotypes = dict({ + "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", + "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) + +# for KD +config.teacher_pth = "/home/fboutros/DartFaceNet/outputKD/iresnet512" +config.teacher_global_step = 295672 +config.network="resnet" +# if use pretrained model (not for resume!) +config.student_pth = "" +config.student_global_step = 0 +config.net_name="DartFaceNet" +config.channel = 16 +config.n_layers = 18 + + +config.w=100 + +if config.dataset == "emoreKD": + config.rec = "data/faces_emore" + config.num_classes = 85742 + config.num_image = 5822653 + config.num_epoch = 26 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + config.eval_step = 5686 + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( + [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) + config.lr_func = lr_step_func + +elif config.dataset == "webface": + config.rec = "data/faces_webface_112x112" + config.num_classes = 10572 + config.num_image = 501195 + config.num_epoch = 34 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "agedb_30"] + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( + [m for m in [20, 28, 32] if m - 1 <= epoch]) + config.lr_func = lr_step_func diff --git a/configs/config_PocketNetM128.py b/configs/config_PocketNetM128.py new file mode 100644 index 0000000..b576d95 --- /dev/null +++ b/configs/config_PocketNetM128.py @@ -0,0 +1,64 @@ +from easydict import EasyDict as edict + +config = edict() +config.dataset = "emoreKD" +config.embedding_size = 128 +config.momentum = 0.9 +config.weight_decay = 5e-4 +config.batch_size = 128 +config.lr = 0.1 +config.output = "output/PocketNetM-128" +config.scale=1.0 +config.global_step=0 +config.s=64.0 +config.m=0.5 +config.test_output="eval" + +config.genotypes = dict({ + "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", + "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) + +# for KD +config.teacher_pth = "output/iresnet128" +config.teacher_global_step = 295672 +config.teacher_network="resnet" + +# if use pretrained model (not for resume!) +config.student_pth = "" +config.student_global_step = 0 +config.net_name="PocketNetM" +if (config.net_name=="PocketNetS"): + config.channel=16 + config.n_layers=18 +elif (config.net_name=="PocketNetM"): + config.channel = 32 + config.n_layers = 9 + +config.w=100 + +if config.dataset == "emoreKD": + config.rec = "data/faces_emore" + config.num_classes = 85742 + config.num_image = 5822653 + config.num_epoch = 26 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + config.eval_step = 5686 + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( + [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) + config.lr_func = lr_step_func + +elif config.dataset == "webface": + config.rec = "data/faces_webface_112x112" + config.num_classes = 10572 + config.num_image = 501195 + config.num_epoch = 34 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( + [m for m in [20, 28, 32] if m - 1 <= epoch]) + config.lr_func = lr_step_func diff --git a/configs/config_PocketNetM256.py b/configs/config_PocketNetM256.py new file mode 100644 index 0000000..b50541c --- /dev/null +++ b/configs/config_PocketNetM256.py @@ -0,0 +1,64 @@ +from easydict import EasyDict as edict + +config = edict() +config.dataset = "emoreKD" +config.embedding_size = 256 +config.momentum = 0.9 +config.weight_decay = 5e-4 +config.batch_size = 128 +config.lr = 0.1 +config.output = "output/PocketNetM-256" +config.scale=1.0 +config.global_step=0 +config.s=64.0 +config.m=0.5 +config.test_output="eval" + +config.genotypes = dict({ + "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", + "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) + +# for KD +config.teacher_pth = "output/iresnet256" +config.teacher_global_step = 295672 +config.teacher_network="resnet" + +# if use pretrained model (not for resume!) +config.student_pth = "" +config.student_global_step = 0 +config.net_name="PocketNetM" +if (config.net_name=="PocketNetS"): + config.channel=16 + config.n_layers=18 +elif (config.net_name=="PocketNetM"): + config.channel = 32 + config.n_layers = 9 + +config.w=100 + +if config.dataset == "emoreKD": + config.rec = "data/faces_emore" + config.num_classes = 85742 + config.num_image = 5822653 + config.num_epoch = 26 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + config.eval_step = 5686 + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( + [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) + config.lr_func = lr_step_func + +elif config.dataset == "webface": + config.rec = "data/faces_webface_112x112" + config.num_classes = 10572 + config.num_image = 501195 + config.num_epoch = 34 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( + [m for m in [20, 28, 32] if m - 1 <= epoch]) + config.lr_func = lr_step_func diff --git a/configs/config_PocketNetS128.py b/configs/config_PocketNetS128.py new file mode 100644 index 0000000..621d836 --- /dev/null +++ b/configs/config_PocketNetS128.py @@ -0,0 +1,62 @@ +from easydict import EasyDict as edict + +config = edict() +config.dataset = "emoreKD" +config.embedding_size = 128 +config.momentum = 0.9 +config.weight_decay = 5e-4 +config.batch_size = 128 +config.lr = 0.1 +config.output = "output/PocketNetS-128" +config.scale=1.0 +config.global_step=0 +config.s=64.0 +config.m=0.5 +config.test_output="eval" + +config.genotypes = dict({ + "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", + "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) + +# for KD +config.teacher_pth = "output/iresnet128" +config.teacher_global_step = 295672 +# if use pretrained model (not for resume!) +config.student_pth = "" +config.student_global_step = 0 +config.net_name="PocketNetS" +if (config.net_name=="PocketNetS"): + config.channel=16 + config.n_layers=18 +elif (config.net_name=="PocketNetM"): + config.channel = 32 + config.n_layers = 9 + +config.w=100 + +if config.dataset == "emoreKD": + config.rec = "data/faces_emore" + config.num_classes = 85742 + config.num_image = 5822653 + config.num_epoch = 26 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + config.eval_step = 5686 + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( + [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) + config.lr_func = lr_step_func + +elif config.dataset == "webface": + config.rec = "data/faces_webface_112x112" + config.num_classes = 10572 + config.num_image = 501195 + config.num_epoch = 34 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( + [m for m in [20, 28, 32] if m - 1 <= epoch]) + config.lr_func = lr_step_func diff --git a/configs/config_PocketNetS256.py b/configs/config_PocketNetS256.py new file mode 100644 index 0000000..565925e --- /dev/null +++ b/configs/config_PocketNetS256.py @@ -0,0 +1,64 @@ +from easydict import EasyDict as edict + +config = edict() +config.dataset = "emoreKD" +config.embedding_size = 256 +config.momentum = 0.9 +config.weight_decay = 5e-4 +config.batch_size = 128 +config.lr = 0.1 +config.output = "output/PocketNetS-256" +config.scale=1.0 +config.global_step=0 +config.s=64.0 +config.m=0.5 + +config.genotypes = dict({ + "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", + "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) + + +config.test_output="eval" + +# for KD +config.teacher_pth = "output/iresnet256" +config.teacher_global_step = 295672 +# if use pretrained model (not for resume!) +config.student_pth = "" +config.student_global_step = 0 +config.net_name="PocketNetS" +if (config.net_name=="PocketNetS"): + config.channel=16 + config.n_layers=18 +elif (config.net_name=="PocketNetM"): + config.channel = 32 + config.n_layers = 9 + +config.w=100 + +if config.dataset == "emoreKD": + config.rec = "data/faces_emore" + config.num_classes = 85742 + config.num_image = 5822653 + config.num_epoch = 26 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + config.eval_step = 5686 + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( + [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) + config.lr_func = lr_step_func + +elif config.dataset == "webface": + config.rec = "data/faces_webface_112x112" + config.num_classes = 10572 + config.num_image = 501195 + config.num_epoch = 34 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( + [m for m in [20, 28, 32] if m - 1 <= epoch]) + config.lr_func = lr_step_func diff --git a/configs/config_example.py b/configs/config_example.py new file mode 100644 index 0000000..e324889 --- /dev/null +++ b/configs/config_example.py @@ -0,0 +1,66 @@ +from easydict import EasyDict as edict + +config = edict() +config.dataset = "emoreKD" +config.embedding_size = 128 +config.momentum = 0.9 +config.weight_decay = 5e-4 +config.batch_size = 128 +config.lr = 0.1 +config.output = "output/PocketNetM-128" +config.scale=1.0 +config.global_step=0 +config.s=64.0 +config.m=0.5 + + +config.test_output="eval" + +config.genotypes = dict({ + "softmax_cifar10": "Genotype(normal=[[('dw_conv_7x7', 0), ('dw_conv_3x3', 1)], [('dw_conv_1x1', 1), ('dw_conv_1x1', 2)], [('max_pool_3x3', 2), ('dw_conv_7x7', 3)], [('dw_conv_5x5', 4), ('max_pool_3x3', 0)]], normal_concat=range(2, 6), reduce=[[('max_pool_3x3', 0), ('dw_conv_7x7', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)], [('max_pool_3x3', 0), ('max_pool_3x3', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))", + "softmax_casia": "Genotype(normal=[[('dw_conv_3x3', 0), ('dw_conv_1x1', 1)], [('dw_conv_3x3', 2), ('dw_conv_5x5', 0)], [('dw_conv_3x3', 3), ('dw_conv_3x3', 0)], [('dw_conv_3x3', 4), ('skip_connect', 0)]], normal_concat=range(2, 6), reduce=[[('dw_conv_3x3', 1), ('dw_conv_7x7', 0)], [('skip_connect', 2), ('dw_conv_5x5', 1)], [('max_pool_3x3', 0), ('skip_connect', 2)], [('max_pool_3x3', 0), ('max_pool_3x3', 1)]], reduce_concat=range(2, 6))" }) + +# for KD +config.teacher_pth = "output/iresnet128" +config.teacher_global_step = 295672 +config.teacher_network="resnet" + +# if use pretrained model (not for resume!) +config.student_pth = "" +config.student_global_step = 0 +config.net_name="PocketNetM" +if (config.net_name=="PocketNetS"): + config.channel=16 + config.n_layers=18 +elif (config.net_name=="PocketNetM"): + config.channel = 32 + config.n_layers = 9 + +config.w=100 + +if config.dataset == "emoreKD": + config.rec = "data/faces_emore" + config.num_classes = 85742 + config.num_image = 5822653 + config.num_epoch = 26 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + config.eval_step = 5686 + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < -1 else 0.1 ** len( + [m for m in [8, 14, 20, 25] if m - 1 <= epoch]) + config.lr_func = lr_step_func + +elif config.dataset == "webface": + config.rec = "data/faces_webface_112x112" + config.num_classes = 10572 + config.num_image = 501195 + config.num_epoch = 34 + config.warmup_epoch = -1 + config.val_targets = ["lfw", "cfp_fp", "cfp_ff", "agedb_30", "calfw", "cplfw"] + + def lr_step_func(epoch): + return ((epoch + 1) / (4 + 1)) ** 2 if epoch < config.warmup_epoch else 0.1 ** len( + [m for m in [20, 28, 32] if m - 1 <= epoch]) + config.lr_func = lr_step_func