Update scripts/0_generate_list.py
Browse files- scripts/0_generate_list.py +51 -0
scripts/0_generate_list.py
CHANGED
|
@@ -903,3 +903,54 @@ for dset in ['DIV2K_train_pair', 'DIV2K_valid_pair']: # train, test
|
|
| 903 |
for item in list_file:
|
| 904 |
fp.write('{} {} {}\n'.format(item[0], item[1], None))
|
| 905 |
print(input_folder, total_ct)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
for item in list_file:
|
| 904 |
fp.write('{} {} {}\n'.format(item[0], item[1], None))
|
| 905 |
print(input_folder, total_ct)
|
| 906 |
+
|
| 907 |
+
|
| 908 |
+
# CDD11: composite
|
| 909 |
+
base_rt = f"/home/work/shared-fi-datasets-01/users/hsiang.chen/Project/Datasets/IR"
|
| 910 |
+
|
| 911 |
+
rt = os.path.join(base_rt, "Composite/CDD11")
|
| 912 |
+
meta_folder = os.path.join(rt, "metas")
|
| 913 |
+
os.makedirs(meta_folder, exist_ok=True)
|
| 914 |
+
for dset in ['CDD-11_train']: # train
|
| 915 |
+
input_folder = os.path.join(rt, dset)
|
| 916 |
+
list_file = []
|
| 917 |
+
total_ct = 0
|
| 918 |
+
for distortion in os.listdir(input_folder):
|
| 919 |
+
if distortion == "clear":
|
| 920 |
+
continue
|
| 921 |
+
distortion_folder = os.path.join(input_folder, distortion)
|
| 922 |
+
clear_folder = os.path.join(input_folder, "clear")
|
| 923 |
+
for ct, sample in enumerate(os.listdir(distortion_folder)):
|
| 924 |
+
print(ct, end='\r')
|
| 925 |
+
if ".png" in sample or ".jpg" in sample or ".jpeg" in sample or ".bmp" in sample or ".tif" in sample or ".JPG" in sample or ".PNG" in sample:
|
| 926 |
+
lq_file = os.path.join(distortion_folder, sample)
|
| 927 |
+
hq_file = os.path.join(clear_folder, sample)
|
| 928 |
+
list_file.append((lq_file, hq_file, distortion))
|
| 929 |
+
total_ct += 1
|
| 930 |
+
|
| 931 |
+
with open(os.path.join(meta_folder,'train.list'), 'w') as fp:
|
| 932 |
+
for item in list_file:
|
| 933 |
+
fp.write('{} {} {}\n'.format(item[0], item[1], item[2]))
|
| 934 |
+
print(input_folder, total_ct)
|
| 935 |
+
|
| 936 |
+
for dset in ['CDD-11_test']: # test
|
| 937 |
+
input_folder = os.path.join(rt, dset)
|
| 938 |
+
for distortion in os.listdir(input_folder):
|
| 939 |
+
total_ct = 0
|
| 940 |
+
list_file = []
|
| 941 |
+
if distortion == "clear":
|
| 942 |
+
continue
|
| 943 |
+
distortion_folder = os.path.join(input_folder, distortion)
|
| 944 |
+
clear_folder = os.path.join(input_folder, "clear")
|
| 945 |
+
for ct, sample in enumerate(os.listdir(distortion_folder)):
|
| 946 |
+
print(ct, end='\r')
|
| 947 |
+
if ".png" in sample or ".jpg" in sample or ".jpeg" in sample or ".bmp" in sample or ".tif" in sample or ".JPG" in sample or ".PNG" in sample:
|
| 948 |
+
lq_file = os.path.join(distortion_folder, sample)
|
| 949 |
+
hq_file = os.path.join(clear_folder, sample)
|
| 950 |
+
list_file.append((lq_file, hq_file))
|
| 951 |
+
total_ct += 1
|
| 952 |
+
|
| 953 |
+
with open(os.path.join(meta_folder,'test_{}.list'.format(distortion)), 'w') as fp:
|
| 954 |
+
for item in list_file:
|
| 955 |
+
fp.write('{} {} {}\n'.format(item[0], item[1], distortion))
|
| 956 |
+
print(distortion_folder, total_ct)
|