MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / extract

Method extract

PATH/core/testers/reid_tester.py:167–203  ·  view source on GitHub ↗
(self, data_loader)

Source from the content-addressed store, hash-verified

165 pass
166
167 def extract(self, data_loader):
168 config = self.config
169 ginfo = self.ginfo
170 tmp = self.tmp
171
172 self.pre_run()
173 end = time.time()
174 self.model.eval()
175
176 for i, tmp.input in enumerate(data_loader):
177 tmp.vdata_time.update(time.time() - end)
178 self.prepare_data()
179
180 tmp.current_step = i + 1
181 with torch.no_grad():
182 self.forward()
183 self.gather_result()
184
185 tmp.vbatch_time.update(time.time() - end)
186 end = time.time()
187
188 if tmp.current_step % config.print_freq == 0 and ginfo.task_rank == 0:
189 print(
190 'Extract Features: [{0}/{1}]\t'
191 'task{task_id:<2}: {task_name}\t'
192 'Time {batch_time.avg:.3f} (ETA:{eta:.2f}h) ({data_time.avg:.3f})\t'
193 .format(i + 1, len(data_loader),
194 task_id=ginfo.task_id, task_name=ginfo.task_name,
195 batch_time=tmp.vbatch_time,
196 eta=(config.max_iter-tmp.current_step)*tmp.vbatch_time.avg/3600,
197 data_time=tmp.vdata_time))
198
199 all_features = torch.cat(tmp.features_list)
200 all_labels = torch.cat(tmp.labels_list)
201 all_camera_ids = torch.cat(tmp.camera_ids_list)
202 # all_features = F.normalize(all_features)
203 return all_features, all_labels, all_camera_ids
204
205 def run(self):
206 config = self.config

Callers 1

runMethod · 0.95

Calls 6

pre_runMethod · 0.95
forwardMethod · 0.95
gather_resultMethod · 0.95
updateMethod · 0.45
prepare_dataMethod · 0.45
catMethod · 0.45

Tested by

no test coverage detected