diff --git a/.github/workflows/tests_full.yaml b/.github/workflows/tests_full.yaml new file mode 100644 index 0000000..cf1949b --- /dev/null +++ b/.github/workflows/tests_full.yaml @@ -0,0 +1,41 @@ +name: "Full set of tests for PRs and master branch" +on: + push: + branches: + - "master" + pull_request: + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + name: Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install Nox + run: pip install nox==2024.03.02 + - name: Run tests + run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}" + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Install Nox + run: pip install nox==2024.03.02 + - name: Lint + run: nox --non-interactive --error-on-missing-interpreter --session "lint" diff --git a/.github/workflows/tests_reduced.yaml b/.github/workflows/tests_reduced.yaml new file mode 100644 index 0000000..a645b5a --- /dev/null +++ b/.github/workflows/tests_reduced.yaml @@ -0,0 +1,40 @@ +name: "Reduced set of tests for push events" +on: + push: + branches-ignore: + - master + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11"] + name: Python ${{ matrix.python-version }} + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install Nox + run: pip install nox==2024.03.02 + - name: Run tests + run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}" + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Install Nox + run: pip install nox==2024.03.02 + - name: Lint + run: nox --non-interactive --error-on-missing-interpreter --session "lint" diff --git a/noxfile.py b/noxfile.py index 6fcdb72..8779177 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,8 +13,13 @@ def lint(session): session.run('flake8', *args) -@nox.session +@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"]) def tests(session): + session.install( + 'torch==2.2.1', + 'torchvision', + '--index-url', 'https://download.pytorch.org/whl/cpu' + ) session.install('.') session.install('pytest') session.install('pytest-mock') diff --git a/src/pytorch_fid/fid_score.py b/src/pytorch_fid/fid_score.py index ac82b53..5102a4b 100755 --- a/src/pytorch_fid/fid_score.py +++ b/src/pytorch_fid/fid_score.py @@ -64,8 +64,9 @@ def tqdm(x): help=('Dimensionality of Inception features to use. ' 'By default, uses pool3 features')) parser.add_argument('--save-stats', action='store_true', - help=('Generate an npz archive from a directory of samples. ' - 'The first path is used as input and the second as output.')) + help=('Generate an npz archive from a directory of ' + 'samples. The first path is used as input and the ' + 'second as output.')) parser.add_argument('path', type=str, nargs=2, help=('Paths to the generated images or ' 'to .npz statistic files')) @@ -307,7 +308,11 @@ def main(): num_workers = args.num_workers if args.save_stats: - save_fid_stats(args.path, args.batch_size, device, args.dims, num_workers) + save_fid_stats(args.path, + args.batch_size, + device, + args.dims, + num_workers) return fid_value = calculate_fid_given_paths(args.path,