preprocess.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:bob.bio.base 作者: bioidiap 项目源码 文件源码
def main(command_line_parameters=None):
  """Preprocesses the given image with the given preprocessor."""
  args = command_line_arguments(command_line_parameters)

  logger.debug("Loading preprocessor")
  preprocessor = bob.bio.base.load_resource(' '.join(args.preprocessor), "preprocessor")

  logger.debug("Loading input data from file '%s'%s", args.input_file, " and '%s'" % args.annotation_file if args.annotation_file is not None else "")
  data = preprocessor.read_original_data(BioFile(1, args.input_file, 2), "", "")
  annotations = bob.db.base.annotations.read_annotation_file(args.annotation_file, 'named') if args.annotation_file is not None else None

  logger.info("Preprocessing data")
  preprocessed = preprocessor(data, annotations)
  preprocessor.write_data(preprocessed, args.output_file)
  logger.info("Wrote preprocessed data to file '%s'", args.output_file)

  if args.convert_as_image is not None:
    converted = bob.core.convert(preprocessed, 'uint8', dest_range=(0,255), source_range=(numpy.min(preprocessed), numpy.max(preprocessed)))
    bob.io.base.save(converted, args.convert_as_image)
    logger.info("Wrote preprocessed data to image file '%s'", args.convert_as_image)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号