Skip to content

Commit

Permalink
Merge pull request #64 from egoist945402376/main
Browse files Browse the repository at this point in the history
FID calculator used for evaluating generated images.
  • Loading branch information
chairc authored Apr 22, 2024
2 parents 87a2227 + 58258e4 commit b47850d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tools/FID_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import subprocess


def run_fid_command(generated_image_folder, dataset_image_folder, dim=2048):

command = f'python -m pytorch_fid {generated_image_folder} {dataset_image_folder} --dim={dim}'

try:

result = subprocess.run(command, shell=True, check=True, text=True, capture_output=True)

print("Successfully calculate FID score!")
print(result.stdout)
except subprocess.CalledProcessError as e:
print("Failed to calculate the FID score:")
print(e.stderr)


# Modify your path to dataset images folder and generated images folder.
generated_image_folder = 'path_to_generated_image_folder'
dataset_image_folder = 'path_to_dataset_image_folder'


# dimensions options: 768/ 2048
# Choose 768 for fast calculation and reduced memory requirement
# choose 2048 for better calculation
# default: 2048
dimensions = 2048
# run
run_fid_command(generated_image_folder, dataset_image_folder, dimensions)

0 comments on commit b47850d

Please sign in to comment.