Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The weights and the model are exactly the same as in [the official Tensorflow im
Install from [pip](https://pypi.org/project/pytorch-fid/):

```
pip install pytorch-fid
pip install git+https://github.com/XavierJiezou/pytorch-fid.git
```

Requirements:
Expand Down
5 changes: 2 additions & 3 deletions src/pytorch_fid/fid_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"""

import os
import glob
import pathlib
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser

Expand Down Expand Up @@ -268,9 +269,7 @@ def compute_statistics_of_path(path, model, batch_size, dims, device, num_worker
m, s = f["mu"][:], f["sigma"][:]
else:
path = pathlib.Path(path)
files = sorted(
[file for ext in IMAGE_EXTENSIONS for file in path.glob("*.{}".format(ext))]
)
files = sorted([file for ext in IMAGE_EXTENSIONS for file in glob.glob(os.path.join(path, '**/*.{}'.format(ext)), recursive=True)]) # 支持递归搜索子目录
m, s = calculate_activation_statistics(
files, model, batch_size, dims, device, num_workers
)
Expand Down