Skip to content

Commit

Permalink
rebase commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kwotsin committed Mar 31, 2020
0 parents commit 3f60827
Show file tree
Hide file tree
Showing 144 changed files with 12,670 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Python CircleCI 2.1 configuration file
version: 2.1
orbs:
codecov: codecov/[email protected]
jobs:
build:
# machine:
# image: ubuntu-1604:201903-01 # recommended linux image - includes Ubuntu 16.04, docker 18.09.3, docker-compose 1.23.1

docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.6.9

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install pip==19.2.3 && pip install -r requirements.txt
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}

# run tests!
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose
# https://pytest.org
# https://nose.readthedocs.io
- run:
name: run tests
command: |
. venv/bin/activate
python -m pytest --cov=./ --cov-report=xml:coverage.xml tests
- codecov/upload:
file: ./coverage.xml
token: 8caf88d1-28eb-40a3-8a4a-85ad8dc90e88

- store_artifacts:
path: test-reports
destination: test-reports
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[report]
exclude_lines =
if __name__ == .__main__.:

[run]
omit =
*test*
torch_mimicry/datasets/imagenet/*
19 changes: 19 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
image: latest

python:
version: 3.6
system_packages: true
install:
- requirements: docs/requirements.txt
- method: setuptools
path: .

formats: []
2 changes: 2 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[style]
based_on_style = pep8
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Kwot Sin Lee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
247 changes: 247 additions & 0 deletions README.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions docs/gallery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Gallery
We provide randomly sampled, non-cherry picked images for various datasets as produced by InfoMax-GAN.

### LSUN-Bedroom
Resolution: 128 x 128

![alt text](https://github.com/kwotsin/mimicry/blob/master/docs/images/lsun_bedroom_128.png "LSUN-Bedroom (128 x 128)")

### CelebA
Resolution: 128 x 128

![alt text](https://github.com/kwotsin/mimicry/blob/master/docs/images/celeba_128.png "CelebA (128 x 128)")

### STL-10
Resolution: 48 x 48

![alt text](https://github.com/kwotsin/mimicry/blob/master/docs/images/stl10_48.png "STL-10 (48 x 48)")

### ImageNet
Resolution: 32 x 32

![alt text](https://github.com/kwotsin/mimicry/blob/master/docs/images/imagenet_32.png "ImageNet (32 x 32)")

### CIFAR-10
Resolution: 32 x 32

![alt text](https://github.com/kwotsin/mimicry/blob/master/docs/images/cifar10.png "CIFAR-10 (32 x 32)")

### CIFAR-100
Resolution: 32 x 32

![alt text](https://github.com/kwotsin/mimicry/blob/master/docs/images/cifar100.png "CIFAR-100 (32 x 32)")
Binary file added docs/images/celeba_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/cifar10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/cifar100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/imagenet_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lsun_bedroom_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/mimicry_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/stl10_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx
sphinx_rtd_theme
56 changes: 56 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import datetime
import sphinx_rtd_theme
import doctest
import torch_mimicry

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]

source_suffix = '.rst'
master_doc = 'index'

author = 'Kwot Sin Lee'
project = 'torch_mimicry'
copyright = '{}, {}'.format(datetime.datetime.now().year, author)

version = torch_mimicry.__version__
release = torch_mimicry.__version__

html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

doctest_default_flags = doctest.NORMALIZE_WHITESPACE
intersphinx_mapping = {'python': ('https://docs.python.org/', None)}

html_theme_options = {
'collapse_navigation': False,
'display_version': True,
'logo_only': True,
}

html_logo = '_static/img/pyg_logo_text.svg'
html_static_path = ['_static']
html_context = {'css_files': ['_static/css/custom.css']}

add_module_names = False


def setup(app):
def skip(app, what, name, obj, skip, options):
members = [
'__init__',
'__repr__',
'__weakref__',
'__dict__',
'__module__',
]
return True if name in members else skip

app.connect('autodoc-skip-member', skip)
30 changes: 30 additions & 0 deletions examples/sngan_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import torch
import torch.optim as optim
import torch_mimicry as mmc
from torch_mimicry.nets import sngan

if __name__ == "__main__":
# Data handling objects
dataset = mmc.datasets.load_dataset(root='./datasets', name='cifar10')
dataloader = torch.utils.data.DataLoader(
dataset, batch_size=64, shuffle=True, num_workers=4)

# Define models and optimizers
netG = sngan.ResNetGenerator32()
netD = sngan.ResNetDiscriminator32()
optD = optim.Adam(netD.parameters(), 2e-4, betas=(0.0, 0.9))
optG = optim.Adam(netG.parameters(), 2e-4, betas=(0.0, 0.9))

# Start training
trainer = mmc.training.Trainer(
netD=netD,
netG=netG,
optD=optD,
optG=optG,
n_dis=5,
num_steps=100000,
lr_decay='linear',
dataloader=dataloader,
log_dir='./log/example')

trainer.train()
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
filterwarnings =
ignore::DeprecationWarning
17 changes: 17 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
numpy>=1.15.4
scipy>=1.0.1
requests>=2.22.0
tensorflow>=1.14.0
torchvision>=0.4.0
six>=1.12.0
matplotlib>=3.1.1
torch>=1.2.0
Pillow>=6.2.0
scikit-image>=0.15.0
pytest>=5.3.2
scikit-learn>=0.20.1
future>=0.17.1
pytest-cov>=2.8.1
pandas>=0.25.3
psutil>=5.7.0
yapf>=0.29.0
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[metadata]
description-file = README.md

[aliases]
test=pytest

[tool:pytest]
addopts = --capture=no --cov
62 changes: 62 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from setuptools import setup, find_packages

__version__ = '0.1.4'
url = 'https://github.com/kwotsin/mimicry'

install_requires = [
'numpy>=1.15.4',
'scipy>=1.0.1',
'requests>=2.22.0',
'tensorflow>=1.14.0',
'torchvision>=0.4.0',
'six>=1.12.0',
'matplotlib>=3.1.1',
'torch>=1.2.0',
'Pillow>=6.2.0',
'scikit-image>=0.15.0',
'pytest>=5.3.2',
'scikit-learn>=0.20.1',
'future>=0.17.1',
'pytest-cov>=2.8.1',
'pandas>=0.25.3',
'psutil>=5.7.0',
'yapf>=0.29.0',
]

setup_requires = ['pytest-runner']
tests_require = ['pytest', 'pytest-cov', 'mock']

long_description = """
Mimicry is a lightweight PyTorch library aimed towards the reproducibility of GAN research.
Comparing GANs is often difficult - mild differences in implementations and evaluation methodologies can result in huge performance differences.
Mimicry aims to resolve this by providing:
(a) Standardized implementations of popular GANs that closely reproduce reported scores;
(b) Baseline scores of GANs trained and evaluated under the same conditions;
(c) A framework for researchers to focus on implementation of GANs without rewriting most of GAN training boilerplate code, with support for multiple GAN evaluation metrics.
We provide a model zoo and set of baselines to benchmark different GANs of the same model size trained under the same conditions, using multiple metrics. To ensure reproducibility, we verify scores of our implemented models against reported scores in literature.
"""

setup(
name='torch_mimicry',
version=__version__,
long_description=long_description,
long_description_content_type='text/markdown',
description='Mimicry: Towards the Reproducibility of GAN Research',
author='Kwot Sin Lee',
author_email='[email protected]',
url=url,
download_url='{}/archive/{}.tar.gz'.format(url, __version__),
keywords=[
'pytorch',
'generative-adversarial-networks',
'gans',
'GAN',
],
python_requires='>=3.6',
install_requires=install_requires,
setup_requires=setup_requires,
tests_require=tests_require,
packages=find_packages(),
)
Binary file added tests/datasets/imagenet/test.bin
Binary file not shown.
Loading

0 comments on commit 3f60827

Please sign in to comment.