1027_test.py关于在YUV 格式的Y channel上训练模型,但是输入图像是RGB—YUV—RGB debug的过程

 最终的代码如下:

def main():
    # parse arguments
    args = parse_args()
    if args is None:
        exit()

    if args.gpu_mode and not torch.cuda.is_available():
        raise Exception("No GPU found, please run without --gpu_mode=False")

    # print 'scale factor = ', scale_factor, \
    #     '\ntest_dir =', args.test_dataset,\


    from network import Net_new4 as net
    model = net(num_channels=1, scale_factor=4, d=32, s=5, m=1)
    model.load_state_dict(torch.load(pretrained_model, map_location = torch.device('cpu')))

    image_dir = args.test_dataset
    image_filenames = [join(image_dir, x) for x in sorted(listdir(image_dir)) if is_image_file(x)]
    file_num = len(image_filenames)
    for idx in range(file_num):
        img_ycbcr = Image.open(image_filenames[idx]).convert('YCbCr') 
        img_y, img_cb, img_cr = img_ycbcr.split()
        input_x_t = torch.from_numpy(numpy.zeros((1, 1, np.array(img_y).shape[0], np.array(img_y).shape[1]), dtype='f')) 
        #temp = torch.from_numpy(np.array(img_y))
        input_x_t[0, 0, :, :] = torch.from_numpy(np.array(img_y))
        #print(input_x.size())
        recon_y = model(input_x_t).detach()
        print(recon_y.size())
        #print(recon_y[:,:,:5,:5])
        #temp = recon_y.data.squeeze(0).
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值