add check arg
This commit is contained in:
@@ -216,7 +216,7 @@ Download pre-trained models into `experiments/pretrained_models`.
|
|||||||
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth -P experiments/pretrained_models
|
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.3/RealESRGAN_x4plus_netD.pth -P experiments/pretrained_models
|
||||||
```
|
```
|
||||||
|
|
||||||
**Finetune**
|
**3. Finetune**
|
||||||
|
|
||||||
Modify [options/finetune_realesrgan_x4plus_pairdata.yml](options/finetune_realesrgan_x4plus_pairdata.yml) accordingly, especially the `datasets` part:
|
Modify [options/finetune_realesrgan_x4plus_pairdata.yml](options/finetune_realesrgan_x4plus_pairdata.yml) accordingly, especially the `datasets` part:
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
import cv2
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -8,6 +9,17 @@ def main(args):
|
|||||||
for folder, root in zip(args.input, args.root):
|
for folder, root in zip(args.input, args.root):
|
||||||
img_paths = sorted(glob.glob(os.path.join(folder, '*')))
|
img_paths = sorted(glob.glob(os.path.join(folder, '*')))
|
||||||
for img_path in img_paths:
|
for img_path in img_paths:
|
||||||
|
status = True
|
||||||
|
if args.check:
|
||||||
|
try:
|
||||||
|
img = cv2.imread(img_path)
|
||||||
|
except Exception as error:
|
||||||
|
print(f'Read {img_path} error: {error}')
|
||||||
|
status = False
|
||||||
|
if img is None:
|
||||||
|
status = False
|
||||||
|
print(f'Img is None: {img_path}')
|
||||||
|
if status:
|
||||||
img_name = os.path.relpath(img_path, root)
|
img_name = os.path.relpath(img_path, root)
|
||||||
print(img_name)
|
print(img_name)
|
||||||
txt_file.write(f'{img_name}\n')
|
txt_file.write(f'{img_name}\n')
|
||||||
@@ -34,6 +46,7 @@ if __name__ == '__main__':
|
|||||||
type=str,
|
type=str,
|
||||||
default='datasets/DF2K/meta_info/meta_info_DF2Kmultiscale.txt',
|
default='datasets/DF2K/meta_info/meta_info_DF2Kmultiscale.txt',
|
||||||
help='txt path for meta info')
|
help='txt path for meta info')
|
||||||
|
parser.add_argument('--check', action='store_true', help='Read image to check whether it is ok')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
assert len(args.input) == len(args.root), ('Input folder and folder root should have the same length, but got '
|
assert len(args.input) == len(args.root), ('Input folder and folder root should have the same length, but got '
|
||||||
|
|||||||
Reference in New Issue
Block a user