Merge pull request #1005 from baiyfbupt/cls_qat
support quant cls model in slim module
This commit is contained in:
commit
c77427630c
|
@ -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():
|
||||||
|
|
||||||
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():
|
||||||
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):
|
||||||
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):
|
||||||
|
|
Loading…
Reference in New Issue