def run1(self): """ FGVC evaluation loop """ acc_dict = {} bits_per_pixel = [] self.logger.info('classifiers for evaluation: {}'.format( [m for m in self.fgvc_cnn_model_names])) for cnn_model_name in self.fgvc_cnn_model_names: model_checkpoint = self.get_fgvc_checkpoint(cnn_model_name) if model_checkpoint is None: continue bpp, accs = self.eval_classifier_model( cnn_model=self.get_classifier_instance(cnn_model_name), ckpt_path=model_checkpoint) acc_dict[cnn_model_name] = accs bits_per_pixel.append(bpp) # write results to csv csv_file = os.path.join( self._log_dir, '{}_accuracy_original_{}.csv'.format(cnn_model_name, self._log_number)) write_to_csv(csv_file, [(bpp, *accs)]) # log results accuracy_dicts = [{cnn_model_name: accs}] self.log_results( self.pack_eval_values(bits_per_pixel=[bpp], accuracy_dicts=accuracy_dicts))
def run0(self): """ imagenet evaluation loop """ acc_dict = {} bits_per_pixel = [] self.logger.info('classifiers for evaluation: {}'.format( [m for m in self.imagenet_cnn_model_names])) for cnn_model_name in self.imagenet_cnn_model_names: bpp, accs = self.eval_classifier_model( self.get_classifier_instance(cnn_model_name)) acc_dict[cnn_model_name] = accs bits_per_pixel.append(bpp) # write results to csv csv_file = os.path.join( self._log_dir, '{}_accuracy_original_{}.csv'.format(cnn_model_name, self._log_number)) write_to_csv(csv_file, [(bpp, *accs)]) # log results accuracy_dicts = [{cnn_model_name: accs}] self.log_results( self.pack_eval_values(bits_per_pixel=[bpp], accuracy_dicts=accuracy_dicts))
def _save_results(self, bpp, accs, cnn_model_name): # write results to csv csv_file = os.path.join(self._log_dir, 'cpm_{}_accuracy_{}.csv'.format(cnn_model_name, self._log_number)) write_to_csv(csv_file, [(b, *a) for b, a in zip(bpp, accs)]) # log results accuracy_dicts = [{cnn_model_name: acc} for acc in accs] self.log_results(self.pack_eval_values(bits_per_pixel=bpp, accuracy_dicts=accuracy_dicts))
def _save_results(self, bpp, accs, cnn_model_name): # write results to csv csv_file = os.path.join( self._log_dir, 'webp_{}_accuracy_{}.csv'.format(cnn_model_name, self._log_number)) write_to_csv(csv_file, [(b, *a) for b, a in zip(bpp, accs)]) # log results accuracy_dicts = [{ cnn_model_name: accs[i] } for i, _ in enumerate(self.COMPRESSION_LEVELS)] self.log_results( self.pack_eval_values(bits_per_pixel=bpp, accuracy_dicts=accuracy_dicts))
def _save_results(self, bpp, accs, cnn_model_name): # write results to csv csv_file = os.path.join( self._log_dir, '{}_{}_{}_accuracy_{}.csv'.format(self._rnn_unit, self._loss_name, cnn_model_name, self._log_number)) write_to_csv(csv_file, [(b, *a) for b, a in zip(bpp, accs)]) # log results accuracy_dicts = [{ cnn_model_name: accs[i] } for i in range(self._num_iterations)] self.log_results( self.pack_eval_values(bits_per_pixel=bpp, accuracy_dicts=accuracy_dicts))
def _save_results(self, bpp, distortion_dicts, compression_method, compression_levels): # write results to csv csv_file = os.path.join( self._log_dir, '{}_hvs_{}.csv'.format(compression_method, self._log_number)) csv_rows = [('bpp', *self.DISTORTION_KEYS)] csv_rows.extend([(b, *[dist_dict[k] for k in self.DISTORTION_KEYS]) for b, dist_dict in zip(bpp, distortion_dicts)]) write_to_csv(csv_file, csv_rows) # log results other_info_dicts = None if compression_levels is not None: other_info_dicts = [{'quality': q} for q in compression_levels] self.log_results( self.pack_eval_values(bits_per_pixel=bpp, hvs_dicts=distortion_dicts, other_info_dicts=other_info_dicts))