Skip to content

toshiaki1729/image-assessing-toolbox

Repository files navigation

image-assessing-toolbox

Toolbox for assessing generative models working with PyTorch

Features

  • Generate feature vectors from image dataset
    • With classifiers trained on ImageNet dataset
    • With classifiers trained on danbooru dataset (may be better for anime-like images)
    • Save the vectors as .npz files
  • FID-like score
    • As you know, FID is one of the most common method to evaluate similarity between two datasets which is proposed in GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium by Heusel et al. (Paper (arXiv), GitHub)
    • Evaluate the similarity between two image datasets by using the method similar to FID
      • "similar" because it may not always use Inception v3
      • Approximate the distribution of feature vectors as multidimensional Gaussian and compute the Fréchet distance between two Gaussians.
    • Using pytorch-fid
  • Improved Precision and Recall Metric

Requirements

All required libraries are listed in requirements.txt
Python 3 (developed with 3.10.7)
PyTorch (developed with 1.13.1+cu117, CUDA is needed if you want to use danbooru-pretrained)

I recommend you to use venv to separate environment.

python -m venv venv
./venv/Scripts/activate

or

python -m venv --system-site-packages venv
./venv/Scripts/activate

for minimal install.
After setup above, run following command.

pip install -r requirements.txt

Usage

  1. Use preprocess.py to generate feature vectors from dataset
  2. Use frechet_distance.py or precision_recall.py to evaluate their similality
  3. See the output csv
    • Use simple_visualizer.py if needed

It is said that at least 10,000 images are needed to get meaningful result.
For reference, 50,000 images are used for assessing in the papers of FID or IPR.
This is because distribution of the feature vectors is extremely sparse since their dimensions are so high (like 512, 2048).

About

PyTorch toolbox for assessing generative models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages