crop_DF2K.py不理解
Closed this issue · 1 comments
chuan1093 commented
文章中说“The text background is obtained from DIV2K [1] and Flick2K [59] datasets, in which each image is randomly cropped and upsampled to ×4 ∼16 to synthesize the complex background”,代码中实现的似乎与文章不符,代码中的逻辑也不大理解,可以麻烦稍微介绍一下代码逻辑吗~
for split in SplitNames:
fis = os.listdir(osp.join(TestImgPath, split))
for fi in fis:
KeyLists = os.listdir(osp.join(TestImgPath, split, fi))
for key in KeyLists:
ImgLists = os.listdir(osp.join(TestImgPath, split, fi, key))
for ImgName in ImgLists:
ImgPath = osp.join(TestImgPath, split, fi, key, ImgName)
A = Image.open(ImgPath).convert('RGB')
w,h = A.size
print([split,fi,key,ImgName])
for ss in ScaleLists:
new_w = w*ss//10
new_h = h*ss//10
if ss < ScaleLists[0]:
A = A.resize((new_w, new_h), Image.LANCZOS)
HowmanyEach = min(new_w//CropSize, new_h//CropSize) * 2 * 2
for j in range(HowmanyEach):
_, Crop, V, M = GetHighPatch(A, CropSize)
total = total + 1
SaveName = '{}_{}_{}_{}_{:05d}_{:02d}.png'.format(split, fi, key, ImgName[:-4],j,ss)
Crop.save(os.path.join(SavePath, SaveName))
csxmli2016 commented
文章中说“The text background is obtained from DIV2K [1] and Flick2K [59] datasets, in which each image is randomly cropped and upsampled to ×4 ∼16 to synthesize the complex background”,代码中实现的似乎与文章不符,代码中的逻辑也不大理解,可以麻烦稍微介绍一下代码逻辑吗~
for split in SplitNames: fis = os.listdir(osp.join(TestImgPath, split)) for fi in fis: KeyLists = os.listdir(osp.join(TestImgPath, split, fi)) for key in KeyLists: ImgLists = os.listdir(osp.join(TestImgPath, split, fi, key)) for ImgName in ImgLists: ImgPath = osp.join(TestImgPath, split, fi, key, ImgName) A = Image.open(ImgPath).convert('RGB') w,h = A.size print([split,fi,key,ImgName]) for ss in ScaleLists: new_w = w*ss//10 new_h = h*ss//10 if ss < ScaleLists[0]: A = A.resize((new_w, new_h), Image.LANCZOS) HowmanyEach = min(new_w//CropSize, new_h//CropSize) * 2 * 2 for j in range(HowmanyEach): _, Crop, V, M = GetHighPatch(A, CropSize) total = total + 1 SaveName = '{}_{}_{}_{}_{:05d}_{:02d}.png'.format(split, fi, key, ImgName[:-4],j,ss) Crop.save(os.path.join(SavePath, SaveName))
crop_DF2K.py 这个文件只是将DF2K图像裁剪成图像块,对应的是‘The text background is obtained from DIV2K [1] and Flick2K [59] datasets, in which each image is randomly cropped’,
后面的’upsampled to ×4 ∼16 to synthesize the complex background‘ 是在读取训练数据时用到的,参考