mseitzer / pytorch-fid

Compute FID scores with PyTorch.
Apache License 2.0
3.22k stars 497 forks source link

Enhance file search to include subdirectories using glob [Update fid_score.py] #113

Open XavierJiezou opened 6 days ago

XavierJiezou commented 6 days ago

This PR enhances the file search functionality to include subdirectories by using glob.glob with the recursive=True parameter. This change ensures that all image files within the specified directory and its subdirectories are found, improving the flexibility and robustness of the file search.

Fixed issue

Details

# Before
files = sorted(
    [file for ext in IMAGE_EXTENSIONS for file in path.glob("*.{}".format(ext))]
)

# After
import glob

files = sorted([file for ext in IMAGE_EXTENSIONS for file in glob.glob(os.path.join(path, '**/*.{}'.format(ext)), recursive=True)])