来源
本来想拿DA-CLIP 训练一下old photo,训练代码没成功,毕设没时间就不研究了
github搜old photo复原论文原作者好像没开源训练数据集,所以用了这个SynOld
训练集500对测试集200对
但是readme写的很差,其他什么也没交代
展示
考证
拿GT图去Google搜图
搞了半天勉强搜上
与训练文件夹下第一张GT图相同
目测用的 PASCAL VOC
生成方法估计参考《Bringing Old Photos Back to Life》
分割代码
第一次见这种保存数据集方式,我将它分割回更一般的 GT、LQ两个文件夹
import os
from PIL import Imagedef split_images(input_dir, output_dir):"""Split paired LQ and GT images into separate files.Args:input_dir (str): The path to the directory containing the paired images.output_dir (str): The path to the directory where the split images will be saved."""# Create LQ and GT subdirectories if they do not existlq_dir = os.path.join(output_dir, 'LQ')gt_dir = os.path.join(output_dir, 'GT')os.makedirs(lq_dir, exist_ok=True)os.makedirs(gt_dir, exist_ok=True)for filename in os.listdir(input_dir):if filename.endswith('.jpg'):image_path = os.path.join(input_dir, filename)with Image.open(image_path) as img:# Assuming the images are horizontally pairedwidth, height = img.sizeassert width % 2 == 0, "The width of the image is not even, cannot split into two equal parts."# Extract LQ image (left half)lq_img = img.crop((0, 0, width // 2, height))lq_output_path = os.path.join(lq_dir, os.path.splitext(filename)[0] + '_LQ.jpg')lq_img.save(lq_output_path)# Extract GT image (right half)gt_img = img.crop((width // 2, 0, width, height))gt_output_path = os.path.join(gt_dir, os.path.splitext(filename)[0] + '_GT.jpg')gt_img.save(gt_output_path)print(f"Saved split images: {lq_output_path} and {gt_output_path}")# Set the paths for input and output directories
input_directory = 'E:\\SynOld-main\\test'
output_directory = 'C:\\Users\\86136\\Desktop\\LQ_images\\old photo'# Call the function to split the paired images
split_images(input_directory, output_directory)
只用两行地址
input_directory = 'E:\\SynOld-main\\test'
这是要分割的图像所在文件夹地址,这里只分了test集
output_directory = 'C:\\Users\\86136\\Desktop\\LQ_images\\old photo'这是我的结果保存路径
结果
DA-CLIP自动检测复原结果
很一般,没有inpainting那么惊艳,一般识别为snowy、shadow、JPEG压缩伪影啥的
只有少量小白点去除。
附复原了25张图的相关指标
PSNR: 21.679276 dB;
SSIM: 0.677668
LPIPS : 0.332356