How can i saved pretrained model as "savedmodel" tensorflow format ?
jzoker opened this issue · 9 comments
trying to load the weight from checkpoint and save entire model as ".savedmodel" format. Here is my code:
cfg_path = os.path.join(os.path.dirname(__file__), 'configs/retinaface_res50.yaml')
checkpoint_path = os.path.join(os.path.dirname(__file__), 'checkpoints/cpkt-81')
saved_path = os.path.join(os.path.dirname(__file__), 'retinaface_res50')
def main(_):
cfg = load_yaml(cfg_path)
model = RetinaFaceModel(cfg, training=True)
model.summary()
model.load_weights(checkpoint_path).expect_partial()
model.save(saved_path)
it seem cant load the weights by load_weights():
So how do i save pretrained model as a file in tf2 format ?
Hi, Have you solved this problem now? I also encountered the problem of failing to load the weight.
I would also like to know. Face detection models in saved model format are rare
were you able to solve this?
@tucachmo2202 Thanks. Following this method I converted the model to savedModel format. I then converted the savedModel format to TensorFlow Lite (tflite). But Now using the tflite version I get 16800 anchor points (16800 for bbox, 16800 for landmarks and also for scores). How can convert these points to proper bounding box, landmarks and scores?
@fisakhan Hi,
I guess shape of output is 16800*16? So, if that is true, you may not use NMS for all that bbox. You can put NMS into network like origin model or use NMS with 16800 anchor you receive.
No, its (16800,2), (16800,4) and (16800,10), what is NMS?
No, its (16800,2), (16800,4) and (16800,10), what is NMS?
NMS is Non maximum suppression. You apply NMS for bbox to remove redundant or duplicate bbox (you will get indices then apply for landmarks too). And, if you don't modify the oringin model, I guess you are wrong at something because, it also has NMS (image below).