提交 a2e932c0 编写于 作者: B baiyfbupt

add cls model quant code

上级 309c2e9d
...@@ -51,6 +51,7 @@ from paddleslim.quant import quant_aware, convert ...@@ -51,6 +51,7 @@ from paddleslim.quant import quant_aware, convert
from paddle.fluid.layer_helper import LayerHelper from paddle.fluid.layer_helper import LayerHelper
from eval_utils.eval_det_utils import eval_det_run from eval_utils.eval_det_utils import eval_det_run
from eval_utils.eval_rec_utils import eval_rec_run from eval_utils.eval_rec_utils import eval_rec_run
from eval_utils.eval_cls_utils import eval_cls_run
def main(): def main():
...@@ -105,6 +106,8 @@ def main(): ...@@ -105,6 +106,8 @@ def main():
if alg_type == 'det': if alg_type == 'det':
final_metrics = eval_det_run(exe, config, quant_info_dict, "eval") final_metrics = eval_det_run(exe, config, quant_info_dict, "eval")
elif alg_type == 'cls':
final_metrics = eval_cls_run(exe, quant_info_dict)
else: else:
final_metrics = eval_rec_run(exe, config, quant_info_dict, "eval") final_metrics = eval_rec_run(exe, config, quant_info_dict, "eval")
print(final_metrics) print(final_metrics)
......
...@@ -178,9 +178,12 @@ def main(): ...@@ -178,9 +178,12 @@ def main():
if train_alg_type == 'det': if train_alg_type == 'det':
program.train_eval_det_run( program.train_eval_det_run(
config, exe, train_info_dict, eval_info_dict, is_slim="quant") config, exe, train_info_dict, eval_info_dict, is_slim="quant")
else: elif train_alg_type == 'rec':
program.train_eval_rec_run( program.train_eval_rec_run(
config, exe, train_info_dict, eval_info_dict, is_slim="quant") config, exe, train_info_dict, eval_info_dict, is_slim="quant")
else:
program.train_eval_cls_run(
config, exe, train_info_dict, eval_info_dict, is_slim="quant")
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -65,6 +65,7 @@ class ClsModel(object): ...@@ -65,6 +65,7 @@ class ClsModel(object):
labels = None labels = None
loader = None loader = None
image = fluid.data(name='image', shape=image_shape, dtype='float32') image = fluid.data(name='image', shape=image_shape, dtype='float32')
image.stop_gradient = False
return image, labels, loader return image, labels, loader
def __call__(self, mode): def __call__(self, mode):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册