2^8-我的创作纪念日

机缘

只是不想光闷头在研究,为了能和别人分享研究。


收获

学会了如何写文章。


日常

一般自己的爱好,文章都写的很快。发现确实也可以将学习的东西发出来,正在计划。


成就

深度学习是使用 GoPro 数据集,因为文件夹结构复杂太难用,索性读取文本文件对。

 def __init__(self, opt):
        super(PairedImagePathTextDataset, self).__init__()
        self.opt = opt
        # file client (io backend)
        self.file_client = None
        self.io_backend_opt = opt['io_backend']
        self.mean = opt['mean'] if 'mean' in opt else None
        self.std = opt['std'] if 'std' in opt else None

        # 改写成从文件中读取路径,加一个文件夹路径作为根路径
        self.dataroot = opt['dataroot']
        self.gt_folder, self.lq_folder = self.dataroot, self.dataroot

        # 传入gt和lq的文件路径
        self.gt_path_file = opt['gt_file']
        self.lq_path_file = opt['lq_file']

        # no tmpl
        # noLMDB

        self.paths = paired_paths_from_text([self.lq_path_file, self.gt_path_file], ['lq', 'gt'], self.dataroot)

def paired_paths_from_text(files, keys, dataroot):
    """Scan text to generate image path pairs.

    Args:
        files (list[str]): A list of text file path. The order of list should
        keys (list[str]): A list of keys identifying folders. The order should
        dataroot (str): Path to the root of data.
    Returns:
        dict: Image path pairs that contains lq path and gt path.
    """
    assert len(files) == 2, ('The len of folders should be 2 with [input_files, gt_files]. ' f'But got {len(files)}')
    assert len(keys) == 2, f'The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}'
    input_file, gt_file = files
    input_key, gt_key = keys

    with open(input_file, 'r') as f:
        input_paths = [osp.normpath(line.strip()) for line in f]
    with open(gt_file, 'r') as f:
        gt_paths = [osp.normpath(line.strip()) for line in f]

    assert len(input_paths) == len(gt_paths), (f'{input_key} and {gt_key} datasets have different number of images: '
                                               f'{len(input_paths)}, {len(gt_paths)}.')
    paths = []
    for input_path, gt_path in zip(input_paths, gt_paths):
        input_path = osp.join(dataroot, input_path)
        gt_path = osp.join(dataroot, gt_path)
        paths.append(dict([(f'{input_key}_path', input_path), (f'{gt_key}_path', gt_path)]))
    return paths

憧憬

正在学习:

  • 硬件:嵌入式
  • 软件:深度学习
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值