Beispiel #1
0
    def get_predictions(self, model, weights_path):
        """ Runs the prediction. """

        self.model = model
        self.weights_path = Path(weights_path)
        weights_conf = self._load_weights()
        out_folder = self.output_dir / self._make_basename() / get_timestamp()
        self.logger.info('Results in:\n > {}'.format(out_folder))
        if out_folder.exists():
            self.logger.warning('Directory exists, might overwrite files')
        else:
            out_folder.mkdir(parents=True)
        if weights_conf:
            yaml.dump(weights_conf,
                      (out_folder / 'weights_config.yml').open('w'))
        # Predict and store
        for img_path in self.img_ls:
            output_path = out_folder / img_path.name
            self.logger.info('Processing file\n > {}'.format(img_path))
            start = time()
            sr_img = self._forward_pass(img_path)
            end = time()
            self.logger.info('Elapsed time: {}s'.format(end - start))
            self.logger.info('Result in: {}'.format(output_path))
            imageio.imwrite(output_path, sr_img)
Beispiel #2
0
    def get_session_id(self, basename):
        """ Returns unique session identifier. """

        time_stamp = get_timestamp()

        if basename:
            session_id = '{b}_{ts}'.format(b=basename, ts=time_stamp)
        else:
            session_id = time_stamp
        return session_id