Code Monkey home page Code Monkey logo

alias-free-gan's Introduction

Alias-Free GAN

An unofficial version of Alias-Free Generative Adversarial Networks (https://arxiv.org/abs/2106.12423). This repository was heavily based on Kim Seonghyeon's (rosinality) implementation. The goal of this version is to be maintainable, easy to use, and expand the features of existing implementations. This is built using pytorch and pytorch lightning (a framework that abstracts away much of the hardware specific code).

See open issues unsupported features, planned features, and current bugs.

Licence

MIT licence badge

This project is officially licensed as an MIT project. However, it's requested that you use this repository with the intention of actively elevating historically marginalized communities. Avoid using this project for creating anything that inflicts physical or psychological violence on individuals, groups, or animals.

Financial Support

If you have the financial means please consider contributing to this project or creators of pretrained models.

This project takes money to run because while many continuos integration (ci) tools are free to open source projects, they do not offer the necessary hardware to run tests on GPUs or TPUs. Because of this the ci testing needs to be run using Google Cloud Platform which charges for GPU and TPU instances. Any financial contributions to this project will first go to covering those costs first.

Licenses and contributions for pretrained models is designed to be flexible so please review the information for a particular model before using it.

Buy me a coffee: https://www.buymeacoffee.com/duskvirkus

Tezos Wallet Address: tz1PeE5NQyyjyJdnyqyKdtFN27TvN9j3ZcUe - Only send tezos to this wallet.

About Branches

devel is the default branch and it includes the latest features but may have breaking changes.

stable branch is the latest stable release of the repository the only updates it receives between versions are to the available pretrained models, additional notebooks, and any bug fixes.

Branch All CI GPU pytest TPUs pytest
devel CI gpu pytest on gcloud tpus pytest on gcloud
stable CI gpu pytest on gcloud tpus pytest on gcloud

Examples

Training Process

Example of animation made from samples generated in training process.

training example gif


Linear Interpolations

Example of linear interpolation between two random seeds.

linear interpolation example with ffhq

linear interpolation example with custom model


Circular Interpolation

Example of circular loop interpolation

circular loop example with ffhq

circular loop example with custom model


Open Simplex Noise Loop

Example of open simplex noise loop interpolation.

noise loop example with ffhq

noise loop example with custom model


Rosinality Translate

Example output from converted rosinality translate script.

rosinality translate example with ffhq

rosinality translate example with custom model

Supported Model Architectures

Below is a list of supported model architecture. The hope is to support NVlabs code when it comes out.

model-architecture Base Repository Repository Version Limit [start,end) Description
alias-free-rosinality-v1 https://github.com/rosinality/alias-free-gan-pytorch [fixed model commit on July 7th 2021, _) Based on rosinality implementation after some model fixes.

Notes:

Notebooks

GPU Colab Training Notebook

branch Open in Colab View in GitHub
devel Open In Colab https://github.com/duskvirkus/alias-free-gan/blob/devel/notebooks/GPU_Training-Alias-Free_GAN.ipynb
stable Open In Colab https://github.com/duskvirkus/alias-free-gan/blob/stable/notebooks/GPU_Training-Alias-Free_GAN.ipynb

GPU Colab Inference Notebook

aka generate images and walks

branch Open in Colab View in GitHub
devel Open In Colab https://github.com/duskvirkus/alias-free-gan/blob/devel/notebooks/GPU_Inference_Alias_Free_GAN.ipynb
stable Open In Colab https://github.com/duskvirkus/alias-free-gan/blob/stable/notebooks/GPU_Inference_Alias_Free_GAN.ipynb

TPU Notebooks

Coming at some point in the future.

Pre-trained Models

See pretrained_models.json.

Use model_name as --resume_from argument for trainer.py.

Pretrained models will automatically download using wget but here's link's if that isn't working for some reason. Place them under a pretrained directory in project root directory.

rosinality-ffhq-800k

Description: A 256 model trained by rosinality on ffhq dataset for 800k steps at a batch size of 16.

Contributing

Contribute Pretrained Models

Contributing your trained models for others to transfer learn off of or use in their projects. This helps reduce the training time and resources required to use.

You can do so by creating a pull request to the stable branch. Add information about your model to the to pretrained_models.json using the template below.

        {
            "model_name": "model-name-no-spaces-no-file-extension",
            "creator": "github username",
            "model_architecture": "see model architecture section",
            "description": "Describe your model. What was it trained on? How long was it trained for? Feel free to include links to make donations and suggested donation amounts. Also include licence information such as creative commons or other licencees.",
            "model_size": 512,
            "wget_url": "Please include a link to download your model in you're pull request and I will update this", 
            "sha1": "If you know how to make a sha1 hash then you can fill this out if not leave this blank."
        }

Contribute Notebooks

If you make a notebook and want to share it that is welcome. If it's just a notebook you can just make a pull request to stable. If it requires changes to the code base please open an issue to discuss which branch it should go on.

Other Contributions

Other contributions are welcome but open an issue to discuss what you want to change/add. Unless it's a small non breaking bug fix pull requests may or may not be accepted without discussion beforehand.

alias-free-gan's People

Contributors

duskvirkus avatar pabloppp avatar rosinality avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

alias-free-gan's Issues

Curious about CI costs

I've been thinking about adding CI to clip-guided-diffusion - I have a few integration tests that just run a few forward passes on CPU/GPU. Saw your note about pricing being an issue and it's essentially the main thing preventing me from doing that on a GPU setup in the cloud. For now, I'm fortunate the most of the checkpoints run inference fine on my RTX 2070 that I own.

Assuming you don't have any issue with revealing such info; what are the costs like for CI on the project? Do you have any tips for people trying to do CI with machine learning?

Thanks in advance for any info

TPU issues in Colab

I'd like to thank you in advance for the work you're doing.

I tried the code with TPU and ran into two problems that may be related. Both errors only occur with the TPU instance, the GPU instances are OK. And it is not a priority for me, I just wanted to report what I found.

1) python install.py prints the following error at the end:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behavior is the source of the following dependency conflicts.
earthengine-api 0.1.278 requires google-api-python-client<2,>=1.12.1, but you have google-api-python-client 1.8.0 which is incompatible. Successfully installed cloud-tpu-client-0.10 google-api-python-client-1.8.0 torch-xla-1.9.1

2) trainer.py ends with the following error even if I just run python scripts/trainer.py --help

Traceback (most recent call last):
  File "scripts/trainer.py", line 10, in <module>
    import pytorch_lightning as pl
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/__init__.py", line 20, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.utils import deprecated_metrics, void
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py", line 29, in <module>
    from pytorch_lightning.utilities import rank_zero_deprecation
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/apply_func.py", line 27, in <module>
    from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_AVAILABLE
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/imports.py", line 93, in <module>
    from pytorch_lightning.utilities.xla_device import XLADeviceUtils  # noqa: E402
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/xla_device.py", line 23, in <module>
    import torch_xla.core.xla_model as xm
  File "/usr/local/lib/python3.7/dist-packages/torch_xla/__init__.py", line 101, in <module>
    import _XLAC
ImportError: /usr/local/lib/python3.7/dist-packages/_XLAC.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNK2at10TensorBase8data_ptrIN3c107complexIfEEEEPT_v

Missing .pt file

Hi. If I follow all your cells and instructions in order, I get this once I reach the second cell of "Generate Single Images"

Using Alias-Free GAN version: 1.0.0
Invalid path /content/drive/MyDrive/colab-gpu-alias-free/alias-free-gan/results/training-000005/000145-epoch-checkpoint.pt is not a .pt model file.

I cannot find that file anywhere or any other .pt file for that matter.

Thanks.

DataLoader memory problem

Occurred when training on V100 colab session. Likely standard memory config.

Low priority bug but still worth noting.

Epoch 17:  81% 6080/7499 [54:22<12:41,  1.86it/s, kimgs=1627.126, r_t_stat=0.750, ada_aug_p=0.484256]ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm).
�Traceback (most recent call last):
  File "scripts/trainer.py", line 178, in <module>
  File "scripts/trainer.py", line 175, in cli_main
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 553, in fit
    self._run(model)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 918, in _run
    self._dispatch()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 986, in _dispatch
    self.accelerator.start_training(self)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/accelerators/accelerator.py", line 92, in start_training
    self.training_type_plugin.start_training(trainer)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 161, in start_training
    self._results = trainer.run_stage()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 996, in run_stage
    return self._run_train()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1045, in _run_train
    self.fit_loop.run()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/base.py", line 111, in run
    self.advance(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/fit_loop.py", line 200, in advance
    epoch_output = self.epoch_loop.run(train_dataloader)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/base.py", line 111, in run
    self.advance(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 130, in advance
    batch_output = self.batch_loop.run(batch, self.iteration_count, self._dataloader_idx)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 101, in run
    super().run(batch, batch_idx, dataloader_idx)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/base.py", line 111, in run
    self.advance(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 148, in advance
    result = self._run_optimization(batch_idx, split_batch, opt_idx, optimizer)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 209, in _run_optimization
    self._update_running_loss(result.loss)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 603, in _update_running_loss
    self.accumulated_loss.append(current_loss)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/supporters.py", line 82, in append
    x = x.to(self.memory)
  File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/signal_handling.py", line 66, in handler
    _error_if_any_worker_fails()
RuntimeError: DataLoader worker (pid 873) is killed by signal: Bus error. It is possible that dataloader's workers are out of shared memory. Please try to raise your shared memory limit.
Epoch 17:  81%|████████  | 6080/7499 [54:31<12:43,  1.86it/s, kimgs=1627.126, r_t_stat=0.750, ada_aug_p=0.484256]

ModuleNotFoundError: No module named 'torchtext.legacy'

Hi,

When resuming training from checkpoint, the following error raises:
ModuleNotFoundError: No module named 'torchtext.legacy'
Tried to install an older release of torchtext, but then this error pops up:
ImportError: cannot import name 'QuantStub' from 'torch.ao.quantization'

any clue how to solve this?

Trainer.py error

Hi, first of all many thanks for the repo.
I'm trying to run in Colab:

!python /content/drive/MyDrive/colab-alias-free-gan/alias-free-gan/scripts/trainer.py --help

and I'm getting this error:

/usr/local/lib/python3.7/dist-packages/pytorch_lightning/core/decorators.py:17: LightningDeprecationWarning: Using pytorch_lightning.core.decorators.parameter_validation is deprecated in v1.5, and will be removed in v1.7. It has been replaced by automatic parameters tying with pytorch_lightning.utilities.params_tying.set_shared_parameters
"Using pytorch_lightning.core.decorators.parameter_validation is deprecated in v1.5, "
Traceback (most recent call last):
File "/content/drive/MyDrive/colab-alias-free-gan/alias-free-gan/scripts/trainer.py", line 19, in
from src.alias_free_gan import AliasFreeGAN
File "/content/drive/MyDrive/colab-alias-free-gan/alias-free-gan/scripts/../src/alias_free_gan.py", line 18, in
from src.model import Generator, filter_parameters
File "/content/drive/MyDrive/colab-alias-free-gan/alias-free-gan/scripts/../src/model.py", line 11, in
from src.stylegan2.model import PixelNorm, EqualLinear, EqualConv2d
File "/content/drive/MyDrive/colab-alias-free-gan/alias-free-gan/scripts/../src/stylegan2/model.py", line 18, in
from pytorch_lightning.core.decorators import auto_move_data
ImportError: cannot import name 'auto_move_data' from 'pytorch_lightning.core.decorators' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/core/decorators.py)

Is it a bug? any hint?
many thanks in advance :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.