Skip to main content

A package containing methods to compute FXD score and other popular metrics for Chest X-Rays.

Project description

PyPI

FXD score for PyTorch

An Improved Metric for Evaluating Chest X-Ray Generation Methods

This is a port of the official implementation of FXD Score to PyTorch.

Generative models are widely used to augment data to improve machine learning models trained on insufficient data. The quality of generated data plays a significant role in the model’s performance. Evaluating a quality of the generative models used a challenging problem. Many sample-based evaluation metrics like Fréchet Inception Distance (FID) compare the distributions of real and generated images in a latent space of models trained on the ImageNet dataset. Such metrics work well in evaluating quality of images of common entities but generally fail in case of images from niche domains not present in the ImageNet dataset like chest x-rays. In this work we propose the FXD score which computes Fréchet distance over the latent space of the pretrained TorchXrayVision model. We perform a series of carefully designed experiments to test for necessary conditions for a meaningful metric. Through these experiments we show that the proposed metric shows more discriminability robustness to transformations and is more sensitive to, mode dropping, mode collapsing and overfitting compared to metrics based on ImageNet weights. Which also proves the importance of choosing domain specific representations in evaluating the quality of generative models. We believe that the proposed FXD score will enable researchers in building generation models efficiently which will in turn aid in building better models to analyze patients more accurately.

pipeline

FXD Score is calculated by computing the Fréchet distance between two Gaussians fitted to feature representations of the Inception network.

Installation

All the codes have been tested on Linux (ubuntu)

Install from pip:

pip install pytorch-fxd

Requirements:

  • python3
  • pytorch
  • torchvision
  • pillow
  • numpy
  • scipy
  • pytorch-fid
  • torchxrayvision
  • scikit-image

Usage

To compute the FXD score between two datasets, where images of each dataset are contained in an individual folder:

pytorch-fxd --dataroot path/to/dataset

path/to/dataset must contain two folders: setA and setB

To run the evaluation on GPU, use the flag --cuda

To compute other metric scores, use the flag --all

The scores are by default calculated using Torchxrayvision's pretrained model. To calculate using Inception v3 instead, use the flag --metric fid

To view other optional arguments:

pytorch-fxd --help

License

This implementation is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorch-fxd-0.3.1.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file pytorch-fxd-0.3.1.tar.gz.

File metadata

  • Download URL: pytorch-fxd-0.3.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.1 pkginfo/1.8.2 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3

File hashes

Hashes for pytorch-fxd-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4c4114d566e893fd7c51f9b2490f13a78face0f0fb995b9fb45cdd6acc626c42
MD5 4a4a3856cea56c9ec2f81cf1b258c359
BLAKE2b-256 602a4372ccc576c41af5d539e06701bf8901f8857e0c3d3f7dae6e6fbbc572d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page