MCPcopy Create free account
hub / github.com/DragonisCV/RAM / analyze

Method analyze

scripts/mac_analysis.py:11–28  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9 super().__init__(opt)
10
11 def analyze(self):
12 total_filter_mac = [0.0] * len(self.hook_list)
13 for test_loader in self.test_loaders:
14 test_set_name = test_loader.dataset.opt['name']
15 num_samples = self.opt.get('num_samples',10)
16 print(f'Analyzing {test_set_name}..\n')
17 pbar = tqdm(total=num_samples, desc='')
18 for idx, val_data in enumerate(test_loader):
19 if idx >= num_samples:
20 break
21 tensor_lq = val_data['lq'].to(self.device)
22 imgname = osp.basename(val_data['lq_path'][0])
23 tensor_base = torch.zeros_like(tensor_lq)
24 layer_conductance = self._mask_attribute_conductance(tensor_base, tensor_lq)
25 total_filter_mac = [a + b for a, b in zip(total_filter_mac, layer_conductance)]
26 pbar.set_description(f'Read {imgname}')
27 pbar.update(1)
28 self._save_results(total_filter_mac, 'mac')
29
30 def _mask_attribute_conductance(self, base_img, final_img):
31 total_step = self.opt['total_step']

Callers 1

mainFunction · 0.95

Calls 3

_save_resultsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected