microsoft / Bringing-Old-Photos-Back-to-Life

Bringing Old Photo Back to Life (CVPR 2020 oral)
https://arxiv.org/abs/2004.09484
MIT License
15.15k stars 2.01k forks source link

Hidden files cause the program to fail silently #167

Closed SeaCelo closed 3 years ago

SeaCelo commented 3 years ago

I was puzzled why I could only process one file at a time. Using a Mac, I also got in the habit of deleting the .DS_Store files before each run to avoid the error:

scratch_image = Image.open(scratch_file).convert("RGB")
  File "/anaconda3/envs/py392/lib/python3.9/site-packages/PIL/Image.py", line 2967, in open
    raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file '/Projects/Bringing-Old-Photos-Back-to-Life-master/workshop/input/.DS_Store'

Deleting the hidden file allowed me to process a single image (as long as the size < 1350px). It occurred to me that .DS_Store files were being recreated during the run of the script.

I made the following changes:

In test.py, (line 110):

#input_loader = os.listdir(opt.test_input)
input_loader = [f for f in os.listdir(opt.test_input) if not f.startswith('.')]

In detection.py (line 102):

#imagelist = os.listdir(config.test_path)
imagelist = [f for f in os.listdir(config.test_path) if not f.startswith('.')]

I was then able to run multiple image files and get results. I'm not sure if the problem occurs in other parts of the code.

SeaCelo commented 3 years ago

I also had to make the same change in the file "align_warp_back_multiple_dlib.py":

Line ~368:

f_list = [f for f in os.listdir(origin_url) if not f.startswith('.')]
#for x in os.listdir(origin_url) :
for x in f_list :
raywzy commented 3 years ago

Hi, it seems that the input folder contains some hidden files which don't belong to PNG/JPEG. Adding extra checking for the input files will be fine.

raywzy commented 3 years ago

Feel free to re-open this issue if there is still any problem.