(self)
| 28 | return mask_generator |
| 29 | |
| 30 | def analyze(self): |
| 31 | total_filter_mac = [0.0] * len(self.hook_list) |
| 32 | for test_loader in self.test_loaders: |
| 33 | test_set_name = test_loader.dataset.opt['name'] |
| 34 | num_samples = self.opt.get('num_samples',10) |
| 35 | print(f'Analyzing {test_set_name}..\n') |
| 36 | pbar = tqdm(total=num_samples, desc='') |
| 37 | for idx, val_data in enumerate(test_loader): |
| 38 | if idx >= num_samples: |
| 39 | break |
| 40 | tensor_lq = val_data['lq'].to(self.device) |
| 41 | imgname = osp.basename(val_data['lq_path'][0]) |
| 42 | tensor_base = torch.zeros_like(tensor_lq) |
| 43 | layer_conductance = self._mask_attribute_conductance(tensor_base, tensor_lq) |
| 44 | total_filter_mac = [a + b for a, b in zip(total_filter_mac, layer_conductance)] |
| 45 | pbar.set_description(f'Read {imgname}') |
| 46 | pbar.update(1) |
| 47 | self._save_results(total_filter_mac, 'mac') |
| 48 | |
| 49 | def _mask_attribute_conductance(self, base_img, final_img): |
| 50 | total_step = self.opt['total_step'] |
no test coverage detected