From 333b1b4847f4028f3300f3378bf02fa0bf1c38be Mon Sep 17 00:00:00 2001 From: FlyingQianMM <245467267@qq.com> Date: Mon, 10 Aug 2020 03:26:20 +0000 Subject: [PATCH] getattr(self, 'use_ema', False) in base.py --- paddlex/cv/models/base.py | 4 ++-- paddlex/cv/models/yolo_v3.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddlex/cv/models/base.py b/paddlex/cv/models/base.py index 48cf511..5eb20e7 100644 --- a/paddlex/cv/models/base.py +++ b/paddlex/cv/models/base.py @@ -548,7 +548,7 @@ class BaseAPI: current_save_dir = osp.join(save_dir, "epoch_{}".format(i + 1)) if not osp.isdir(current_save_dir): os.makedirs(current_save_dir) - if hasattr(self, 'use_ema') and self.use_ema: + if getattr(self, 'use_ema', False): self.exe.run(self.ema.apply_program) if eval_dataset is not None and eval_dataset.num_samples > 0: self.eval_metrics, self.eval_details = self.evaluate( @@ -576,7 +576,7 @@ class BaseAPI: log_writer.add_scalar( "Metrics/Eval(Epoch): {}".format(k), v, i + 1) self.save_model(save_dir=current_save_dir) - if hasattr(self, 'use_ema') and self.use_ema: + if getattr(self, 'use_ema', False): self.exe.run(self.ema.restore_program) time_eval_one_epoch = time.time() - eval_epoch_start_time eval_epoch_start_time = time.time() diff --git a/paddlex/cv/models/yolo_v3.py b/paddlex/cv/models/yolo_v3.py index 769ce11..5bbaa2f 100644 --- a/paddlex/cv/models/yolo_v3.py +++ b/paddlex/cv/models/yolo_v3.py @@ -60,7 +60,7 @@ class YOLOv3(PPYOLO): ] assert backbone in backbones, "backbone should be one of {}".format( backbones) - super(YOLOv3, self).__init__('detector') + super(PPYOLO, self).__init__('detector') self.backbone = backbone self.num_classes = num_classes self.anchors = anchors -- GitLab