Saravanan666/pypi-org huggingface dataset:
Package: pytorch-fid-wrapper
pytorch-fid-wrapperA simple wrapper around@mseitzer's greatpytorch-fidwork.The goal is to compute the Fréchet Inception Distance between two sets of imagesin-memoryusing PyTorch.Installationpip install pytorch-fid-wrapperRequires (and will install) (aspytorch-fid):Python >= 3.5PillowNumpyScipyTorchTorchvisionUsageimportpytorch_fid_wrapperaspfw# ---------------------------# -----  Initial Setup  -----# ---------------------------# Optional: set pfw's configuration with your parameters once and for allpfw.set_config(batch_size=BATCH_SIZE,dims=DIMS,device=DEVICE)# Optional: compute real_m and real_s only once, they will not change during trainingreal_m,real_s=pfw.get_stats(real_images)...# -------------------------------------# -----  Computing the FID Score  -----# -------------------------------------val_fid=pfw.fid(fake_images,real_m=real_m,real_s=real_s)# (1)# ORval_fid=pfw.fid(fake_images,real_images=new_real_images)# (2)All_imagesvariables in the example above aretorch.Tensorinstances with shapeN x C x H x W. They will be sent to the appropriate device depending on what you ask for (seeConfig).To compute the FID score between your fake images and some real dataset, you caneitherre-use pre-computed statsreal_m,real_sat each validation stage(1),orprovide another dataset for which the stats will be computed (in addition to your fake images' which are computed in both scenarios)(2). Score is computed inpfw.fid_score.calculate_frechet_distance(...), followingpytorch-fid's implementation.Please refer topytorch-fidfor any documentation on the InceptionV3 implementation or FID calculations.Configpfw.get_stats(...)andpfw.fid(...)need to know what block of the InceptionV3 model to use (dims), on what device to compute inference (device) and with what batch size (batch_size).Default values are inpfw.params:batch_size = 50,dims = 2048anddevice = "cpu". If you want to override those, you have two options:1/ override any of these parameters in the function calls. For instance:pfw.fid(fake_images,new_real_data,device="cuda:0")2/ override the params globally withpfw.set_configand set them for all future calls without passing parameters again. For instance:pfw.set_config(batch_size=100,dims=768,device="cuda:0")...pfw.fid(fake_images,new_real_data)RecognitionRemember to cite their work if usingpytorch-fid-wrapperorpytorch-fid:@misc{Seitzer2020FID,
  author={Maximilian Seitzer},
  title={{pytorch-fid: FID Score for PyTorch}},
  month={August},
  year={2020},
  note={Version 0.1.1},
  howpublished={\url{https://github.com/mseitzer/pytorch-fid}},
}LicenseThis implementation is licensed under the Apache License 2.0.FID was introduced by Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler and Sepp Hochreiter in "GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium", seehttps://arxiv.org/abs/1706.08500The original implementation is by the Institute of Bioinformatics, JKU Linz, licensed under the Apache License 2.0.
Seehttps://github.com/bioinf-jku/TTUR.
Package: pytorch-flame
flameFlame is a library that helps develop neural networks fast and flexibly. It is built on PyTorch Ignite, a high-level library in PyTorch Ecosystem.ContentsWhy flame?ConceptsInstallationGet startedUsageRun your first experimentWhy flame?When developing neural networks people train and evaluate models a lot and repeat these works on many problems. Flame is created for solving two needs:Templates for doing experiments: flame provides templates for neural network development with common utilities like saving checkpoints periodically, resume training, logging, evaluating, etc.The way to add functionalities flexibly: depending on different problems developers have different requirements for the training and testing. They might want to stop the training progress if there is no improvement, plotting the results after each epoch or they just want a vanilla training loop. Now with flame, you can use any on-the-shelf metrics and handlers from Ignite or your own just by editing the configuration file.ConceptsTBDInstallationCreate your new environment with Python 3 and install flame bypip:pipinstallpytorch-flameGet startedUsageFlame provides two commands:Initialize a new projectusage: flame init [-h] [-f] [directory]

positional arguments:
  directory   Directory in which the new project is initialized. If not specified, it will be initialized in the current directory.

optional arguments:
  -h, --help  show this help message and exit
  -f, --full  Whether to create a full template project or not.Run the training or testingusage: flame run [-h] file

positional arguments:
  file        Config file

optional arguments:
  -h, --help  show this help message and exitRun your first experimentLet's get started with a simple experiment: classification on the MNIST dataset.Flame runs experiments with configs so you need to create configs first. Run commandsmkdirmnist-classifcation&&cdmnist-classification
flameinitor you can run just commandflameinitmnist-classificationflame will create the folder and initialize in it. The folder created will have the structure:mnist-classification/
└── configs
    ├── test.yml
    └── train.ymlYou can add-for--fulltoinitcommand for creating an extra filerun.pyin case you prefer runningpython run.pyrather thanflame runfor some reason. Then the structure will be:mnist-classification/
├── configs
│   ├── test.yml
│   └── train.yml
└── run.pyMNIST dataset and the model will be got fromtorchvision, so we need to install it.pipinstalltorchvisionNow, you have all for the training.cdtomnist-classificationand run it byflamerunconfigs/train.ymlTo see how the training is going on, start Tensorboardtensorboard--logdirlogs/Checkpoints will be saved incheckpointsfolder. Say the training is done and you want to evaluate the modelcheckpoints/best_model.pt, for example, change valuecheckpoint.loader.kwargs.pathinconfigs/test.ymltocheckpoints/best_model.pt.checkpoint:loader:module:flame.handlersname:CheckpointLoaderkwargs:path:"'checkpoints/best_model.pt'"Run the following command to start evaluating the model:flamerunconfigs/test.ymlThat's it! You have just completed training and evaluating with flame.
Package: pytorch-functional
Pytorch FunctionalTHIS PROJECT WAS RENAMED!New name is Pytorch Symbolic.The main reason is the ambiguity withtorch.nn.functional.NEW LINKShttps://pytorch-symbolic.readthedocs.io/https://github.com/gahaalt/pytorch-symbolic/https://pypi.org/project/pytorch-symbolic/InstallationInstall new version with pip:pip install pytorch-symbolic
Package: pytorch-fxd
FXD score for PyTorchAn Improved Metric for Evaluating Chest X-Ray Generation MethodsThis 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.FXD Score is calculated by computing theFréchet distancebetween two Gaussians fitted to feature representations of the Inception network.InstallationAll the codes have been tested on Linux (ubuntu)Install frompip:pip install pytorch-fxdRequirements:python3pytorchtorchvisionpillownumpyscipypytorch-fidtorchxrayvisionscikit-imageUsageTo compute the FXD score between two datasets, where images of each dataset are contained in an individual folder:pytorch-fxd --dataroot path/to/datasetpath/to/dataset must contain two folders: setA and setBTo run the evaluation on GPU, use the flag--cudaTo compute other metric scores, use the flag--allThe scores are by default calculated using Torchxrayvision's pretrained model. To calculate using Inception v3 instead, use the flag--metric fidTo view other optional arguments:pytorch-fxd --helpLicenseThis implementation is licensed under the MIT License.
Package: pytorch-fxdt1
FXD Score: An Improved Metric for Evaluating Chest X-Ray Generation MethodsGenerative 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.
Package: pytorch-gan-zoo
GAN-zooTrain and evaluate basic FC-GAN:# train on fashion-mnist
python -m ganzoo.examples.basic_gan.train_fc \
    --z_dim=100 --num_hidden_units=256 \
    --network_type=fc-large \
    --dataset_name=fashion-mnist

# evaluate
python -m ganzoo.examples.basic_gan.eval_fc \
    lightning_logs/version_1/checkpoints/epoch\=99-step\=337600.ckpt \
    --output_dir lightning_logs/version_1/outputsA collection of GAN models implemented in PyTorch:Basic GAN on MNISTcodeConditional GAN on MNISTcodePix2Pix on FACADES datasetcodeReferences - part 1GANarxivWasserstein GANarxivDCGANarxivConditional GANsarxivLSGANarxivSAGANarxivPix2PixarxivPix2Pix-HDarxivPyTorch imp.CycleGANarxivcodeStarGANarxivPyTorch imp.Geometric GANarxivInfoGANarxivBigGANarxivConSinGANarxivcodeOT-GANarxivReferences - part 2Improved Techniques for Training GANsarxivOn Convergence and Stability of GANsarxivWhich Training Methods for GANs do actually Converge?arxivIs generator conditioning causally related to GAN performance?arxivThe unusual effectiveness of averaging in gan trainingarxivcGANs with projection discriminatorarxiv
Package: pytorch-glow
Glow: Generative Flow with Invertible 1x1 Convolutions [Work in Progress]Unofficial PyTorch implementation of "Glow: Generative Flow with Invertible 1x1 Convolutions"The original paper can be foundhere.The code is based off another implementation foundhere.This repository contain the Glow model code and associated training / sampling scripts.This repository is a work in progress. Default parameters may not be optimal!UsageGlow TrainingRun Glow training using config filecfg.toml. Defaults toconfig/cifar10.tomlpython main.py --cfg-path cfg.toml --no-ampcurrently recommend NOT using automatic mixed precision (AMP)Other useful flags:--nb-samples            # number of samples to generate when evaluating [16]
--resume                # resume training from specified checkpoint 
--seed                  # set RNG seed 
--no-save               # disable saving of checkpoints [False]
--no-cuda               # disable the use of CUDA device [False]
--no-amp                # disable the use of automatic mixed precision [False]
--nb-workers            # set number of dataloader workers. [4]
--no-grad-checkpoint    # don't checkpoint gradients [False]
--temperature           # set temperature when sampling at evaluation [0.7]Glow SamplingRun Glow sampling using config filecfg.tomlfrom checkpointcheckpoint.ptusing sample modemode:python main.py --sample --sample-mode mode --resume checkpoint.pt --cfg-path cfg.toml --no-ampOther flags from training will also work during sampling.The sampling modes are:normal: samples random latent and displays corresponding samples, saving tosample.jpgvtemp: samples random latent and varies temperature, dumping samplessamples-vtemp/interpolate: computes latent of dataset items, then linearly interpolates
between them, dumping samples insamples-interpolate/SamplesTODO: add (nice) sample outputsCheckpointsTODO: add pretrained checkpointsTODO:Glow ModelTraining scriptSampling scriptGradient checkpointsPyPi libraryAdd pretrained models / nice samplesCitations:Glow: Generative Flow with Invertible 1x1 ConvolutionsDiederik P. Kingma, Prafulla Dhariwal@misc{kingma2018glow,
      title={Glow: Generative Flow with Invertible 1x1 Convolutions}, 
      author={Diederik P. Kingma and Prafulla Dhariwal},
      year={2018},
      eprint={1807.03039},
      archivePrefix={arXiv},
      primaryClass={stat.ML}
}
Package: pytorch-gradcam
A Simple pytorch implementation of GradCAM[1], and GradCAM++[2]Installationpipinstallpytorch-gradcamSupported torchvision modelsalexnetvggresnetdensenetsqueezenetUsageplease refer toexample.ipynbfor general usage and refer to documentations of each layer-finding functions inutils.pyif you want to know how to settarget_layer_nameproperly.Use your own model and layer:model=MyModel()target_layer=model.my_submodulegradcam=GradCAM(model,target_layer)References:[1] Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization, Selvaraju et al, ICCV, 2017[2] Grad-CAM++: Generalized Gradient-based Visual Explanations for Deep Convolutional Networks, Chattopadhyay et al, WACV, 2018
Package: pytorch-hed
Pytorch Holistically-Nested Edge Detection (HED)Website:davidelanz.github.io/pytorch-hedDocumentation:pytorch-hed.readthedocs.ioThis is a reimplementation in the form of a python package of Holistically-Nested Edge Detection[1]using PyTorch based on the previous pytorch implementation bysniklaus[2]. If you would like to use of this work, please cite the paper accordingly. Also, make sure to adhere to the licensing terms of the authors. Moreover, if you will be making use of this particular implementation[3], please acknowledge it.GitHubRefOriginal version based on Caffehttps://github.com/s9xie/hed[1]Another reimplementation based on Caffehttps://github.com/zeakey/hedOriginal reimplementation based on PyTorchhttps://github.com/sniklaus/pytorch-hed[2]UsageFirst, you have to install the package (stable) withpip install pytorch-hedor, for the current (unstable) versionpip install git+https://github.com/Davidelanz/pytorch-hed.gitUsage:importtorchHED# process a single image filetorchHED.process_file("./images/sample.png","./images/sample_processed.png")# process all images in a foldertorchHED.process_folder("./input_folder","./output_folder")# process a PIL.Image loaded in memory and return a new PIL.Image# img = PIL.Image.open("./images/sample.png")img_hed=torchHED.process_img(img)ResultsInputOriginal Caffe Implementation[1]pytorch-hed[3]References[1]  @inproceedings{Xie_ICCV_2015,
         author = {Saining Xie and Zhuowen Tu},
         title = {Holistically-Nested Edge Detection},
         booktitle = {IEEE International Conference on Computer Vision},
         year = {2015}
     }[2]  @misc{pytorch-hed,
         author = {Simon Niklaus},
         title = {A Reimplementation of {HED} Using {PyTorch}},
         year = {2018},
         howpublished = {\url{https://github.com/sniklaus/pytorch-hed}}
    }[3]  @misc{pytorch-hed-2,
         author = {Davide Lanza},
         title = {The {pytorch-hed} Python Package},
         year = {2020},
         howpublished = {\url{https://github.com/Davidelanz/pytorch-hed}}
    }
Package: pytorch-histogram-matching
pytorch-histogram-matchingInstallationpipinstallpytorch_histogram_matchingUsagefrompytorch_histogram_matchingimportHistogram_Matchingimporttorchdst=torch.randint(0,256,(8,3,512,512)).cuda()/255.ref=torch.randint(0,256,(8,3,512,512)).cuda()/255.dst.requires_grad=Trueref.requires_grad=TrueHM=Histogram_Matching(differentiable=True)rst=HM(dst,ref)Testpythontest.py
Package: pytorch-ialgebra
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default"></script>Pytorch iAlgebraDocument|Paper|ReferencesPytorch iAlgebrais an interactive interpretation library for deep learning onPytorch.Pytorch iAlgebra provides an interactive frame for interpreting a group of deep leanring models using a set of interpretation methods.iAlgebra OperationsOperatorsIdentity$$
[\phi(x)]{i}=\frac{1}{d} \sum{k=0}^{d-1} \mathbb{E}{I{k}}\left[f\left(x_{I_{k} \cup{i}}\right)-f\left(x_{I_{k}}\right)\right]
$$Projection$$
\left[\Pi_{w}(x)\right]{i}=\left{\begin{array}{cc}{\frac{1}{|w|} \sum{k=0}^{|w|-1} \mathbb{E}{I{k}}\left[f\left(x_{I_{k} \cup{i}}\right)-f\left(x_{I_{k}}\right)\right]} & {i \in w} \ {0} & {i \notin w}\end{array}\right.
$$Selection$$
\left[\sigma_{l}(x)\right]{i}=\left[\phi\left(x ; \bar{x}, f{l}\right)\right]_{i}
$$Join$$
\left[x \bowtie x^{\prime}\right]{i}=\frac{1}{2}\left([\phi(x ; \bar{x}, f)]{i}+\left[\phi\left(x^{\prime} ; \bar{x}, f\right)\right]_{i}\right)
$$Anti-Join$$
\left[x \diamond x^{\prime}\right]{i}=\left(\left[\phi\left(x ; x^{\prime}, f\right)\right]{i},\left[\phi\left(x^{\prime} ; x, f\right)\right]_{i}\right)
$$Supportive DNN and Interpretation ModelsDNN ModelsModel Performance on datasetMnistDatasetModelsMnistLeNet-L1LeNet-L2Accuracy98.866%99.020%Model Performance on datasetCifar10DatasetModelsCifar10Vgg19 -L1Vgg19-L2Accuracy98.866%99.020%Interpretation MethodsIn detail, we implement the following interpretation methods as theidentityin Pytorch-iAlgebra.GradSaliencyfrom Simonyanet al.:Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps(CVPR 2013)SmoothGradfrom Smilkovet al.:SmoothGrad: removing noise by adding noiseMaskfrom Fonget al.:Interpretable Explanations of Black Boxes by Meaningful Perturbation(ICCV 2017)GradCamfrom Selvarajuet al.:Grad-CAM:
Visual Explanations from Deep Networks via Gradient-based Localization(ICCV 2017)GuidedBackpropGradfrom Springenberget al.:Striving for Simplicity: The All Convolutional Net(ICLR 2015)InstallationLibrary dependencies for thePytorch-iAlgebra. Before installation, you need to install these with$pipinstall-rrequirements.txtThenPytorch-iAlgebracan be installed by:$pipinstallpytorch-ialgebra
Package: pytorch-icem
PyTorch MPPI ImplementationThis repository implements the improved Cross Entropy Method (iCEM)
with approximate dynamics in pytorch, fromthis paper.MPPI typically requires actual
trajectory samples, butthis papershowed that it could be done with approximate dynamics (such as with a neural network)
using importance sampling.Thus it can be used in place of other trajectory optimization methods
such as the Cross Entropy Method (CEM), or random shooting.Related projectspytorch CEM- alternative sampling based MPCpytorch MPPI- alternative sampling based MPCiCEM- original paper's numpy implementation and experiments codeInstallationpipinstallpytorch-icemfor running tests, install withpipinstallpytorch-icem[test]for development, clone the repository then install in editable modepipinstall-e.UsageSeetests/pendulum_approximate_continuous.pyfor usage with a neural network approximating
the pendulum dynamics. Basic use case is shown belowfrompytorch_icemimportiCEM# create controller with chosen parametersctrl=icem.iCEM(dynamics,terminal_cost,nx,nu,sigma=sigma,warmup_iters=10,online_iters=10,num_samples=N_SAMPLES,num_elites=10,horizon=TIMESTEPS,device=d,)# assuming you have a gym-like envobs=env.reset()foriinrange(100):action=ctrl.command(obs)obs,reward,done,_,_=env.step(action.cpu().numpy())Requirementspytorch (>= 1.0)next state <- dynamics(state, action)function (doesn't have to be true dynamics)stateisK x nx,actionisK x nutrajectory cost <- cost(state, action)function for the whole state action trajectory, T is the horizoncostisK x 1, state isK x T x nx,actionisK x T x nuFeaturesParallel/batch pytorch implementation for accelerated sampling
Package: pytorch-iga
This is a PyTorch implementation of the Inter-environmental Gradient Alignment algorithm proposed by Koyama and Yamaguchi in their paperOut-of-Distribution Generalization
with Maximal Invariant PredictorQuick startInstall pytorch-iga in the terminal:pipinstallpytorch-igaImport IGA in python:fromigaimportIGAIGA is defined with the following parameters:IGA(model,optimizer,criterion,data,num_epochs,batch_size,lamda,verbose=10,device=torch.device("cuda"iftorch.cuda.is_available()else"cpu"),)Parameters:model (torch.nn.Module): neural network model to be trained/tuned
optimizer (torch.optim): pytorch optimizer object such as torch.optim.SGD
criterion (function): loss function for model evaluation
data (list(torch.utils.Dataset)): a list of Datasets for each environment
num_epochs (int): number of training epochs
batch_size (int): number of data points per batch
lamda (float): importance weight of inter-environmental variance
verbose (int): number of iterations in each progress log
device (torch.device): optional, torch.device object, defaults to 'cuda' or 'cpu'Returns:model (torch.nn.Module): updated torch model
IGA_loss (float): ending loss valueExampleto be continued...
Package: pytorch-igniter
Simplifypytorchtraining using a configurable wrapper aroundpytorch-igniteInstallationpipinstallpytorch-igniterDemoSeepytorch-igniter-demoDocumentationView latest documentation atReadTheDocsContinuous IntegrationView continuous integration atTravisCIPyPIView releases onPyPIGitHubView source code onGitHubGitHub tags are automatically released on ReadTheDocs, tested on TravisCI, and deployed to PyPI if successful.