Package: wgandiv-pytorch
WassersteinGAN_DIV-PyTorchUpdate (Feb 22, 2020)The mnist and fmnist models are now available. Their usage is identical to the other models:fromwgandiv_pytorchimportGeneratormodel=Generator.from_pretrained('g-mnist')OverviewThis repository contains an op-for-op PyTorch reimplementation ofWasserstein Divergence for GANs.The goal of this implementation is to be simple, highly extensible, and easy to integrate into your own projects. This implementation is a work in progress -- new features are currently being implemented.At the moment, you can easily:Load pretrained Generate modelsUse Generate models for extended datasetUpcoming features: In the next few days, you will be able to:Quickly finetune an Generate on your own datasetExport Generate models for productionTable of contentsAbout Wasserstein GAN DIVModel DescriptionInstallationUsageLoad pretrained modelsExample: Extended datasetExample: VisualContributingAbout Wasserstein GAN DIVIf you're new to Wasserstein GAN DIV, here's an abstract straight from the paper:In many domains of computer vision, generative adversarial networks (GANs) have achieved great success, among which the fam- ily of Wasserstein GANs (WGANs) is considered to be state-of-the-art due to the theoretical contributions and competitive qualitative performance. However, it is very challenging to approximate the k-Lipschitz constraint required by the Wasserstein-1 metric (W-met). In this paper, we propose a novel Wasserstein divergence (W-div), which is a relaxed version of W-met and does not require the k-Lipschitz constraint.As a concrete application, we introduce a Wasserstein divergence objective for GANs (WGAN-div), which can faithfully approximate W-div through optimization. Under various settings, including progressive growing training, we demonstrate the stability of the proposed WGAN-div owing to its theoretical and practical advantages over WGANs. Also, we study the quantitative and visual performance of WGAN-div on standard image synthesis benchmarks, showing the superior performance of WGAN-div compared to the state-of-the-art methods.Model DescriptionWe have two networks, G (Generator) and D (Discriminator).The Generator is a network for generating images. It receives a random noise z and generates images from this noise, which is called G(z).Discriminator is a discriminant network that discriminates whether an image is real. The input is x, x is a picture, and the output is D of x is the probability that x is a real picture, and if it's 1, it's 100% real, and if it's 0, it's not real.InstallationInstall from pypi:pipinstallwgandiv_pytorchInstall from source:gitclonehttps://github.com/Lornatang/WassersteinGAN_DIV-PyTorch.gitcdWassersteinGAN_DIV-PyTorch
pipinstall-e.UsageLoading pretrained modelsLoad an Wasserstein GAN DIV:fromwgandiv_pytorchimportGeneratormodel=Generator.from_name("g-mnist")Load a pretrained Wasserstein GAN DIV:fromwgandiv_pytorchimportGeneratormodel=Generator.from_pretrained("g-mnist")Example: Extended datasetAs mentioned in the example, if you load the pre-trained weights of the MNIST dataset, it will create a newimgsdirectory and generate 64 random images in theimgsdirectory.importosimporttorchimporttorchvision.utilsasvutilsfromwgandiv_pytorchimportGeneratordevice=torch.device("cuda:0"iftorch.cuda.is_available()else"cpu")model=Generator.from_pretrained("g-mnist")model.to(device)# switch to evaluate modemodel.eval()try:os.makedirs("./imgs")exceptOSError:passwithtorch.no_grad():foriinrange(64):noise=torch.randn(64,100,device=device)fake=model(noise)vutils.save_image(fake.detach(),f"./imgs/fake_{i:04d}.png",normalize=True)print("The fake image has been generated!")Example: Visualcd $REPO$/framework
sh start.shThen open the browser and type in the browser addresshttp://127.0.0.1:10004/.
Enjoy it.ContributingIf you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.I look forward to seeing what the community does with these models!