Skip to content

Commit

Permalink
Add more CI testing via github actions (#130)
Browse files Browse the repository at this point in the history
* Add more CI testing via github actions

* Fix yml

* Add missing run statements

* Remove quotes

* Proper pytorch version

* Remove MAC OS build

* Support only new pytorch versions

* Support only new pytorch versions

* Remove pillow dependency

* Remove fastprogress dependency

* Fix pillow version

* Fix pillow version

* Revamp the readme
  • Loading branch information
avik-pal committed Feb 19, 2020
1 parent e177057 commit 0bd241a
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 22 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci_testing.yml
@@ -0,0 +1,53 @@
name: CI Testing

on: [push, pull_request]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-2019]
python-version: [3.6, 3.7]
pytorch-version: [1.2, 1.3, 1.4, 'nightly']

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Pytorch 1.2
if: matrix.pytorch-version == 1.2
run: |
pip install Pillow==6.1
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install Pytorch 1.3
if: matrix.pytorch-version == 1.3
run: |
pip install Pillow==6.1
pip install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install Pytorch 1.4
if: matrix.pytorch-version == 1.4
run: pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install Pytorch Nightly
if: matrix.pytorch-version == 'nightly'
run: pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install scipy
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest
@@ -1,35 +1,47 @@
name: Python package
name: CI Testing

on: [push]
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
runs-on: macOS-10.15
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: [3.6, 3.7]
pytorch-version: [1.2, 1.3, 1.4, 'nightly']

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Pytorch 1.2
if: matrix.pytorch-version == 1.2
run: pip install Pillow==6.1 torch==1.2.0 torchvision==0.4.0
- name: Install Pytorch 1.3
if: matrix.pytorch-version == 1.3
run: pip install Pillow==6.1 torch==1.3.1 torchvision==0.4.2
- name: Install Pytorch 1.4
if: matrix.pytorch-version == 1.4
run: pip install torch torchvision
- name: Install Pytorch Nightly
if: matrix.pytorch-version == 'nightly'
run: pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install scipy
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
- name: Test with pytest
run: |
pip install pytest
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/rebase.yml
@@ -0,0 +1,26 @@
name: Automatic Rebase
# https://github.com/marketplace/actions/automatic-rebase

on:
issue_comment:
types: [created]
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.community/t5/GitHub-Actions/Workflow-is-failing-if-no-job-can-be-ran-due-to-condition/m-p/38186#M3250
always_job:
name: Always run job
runs-on: ubuntu-latest
steps:
- name: Always run
run: echo "This job is used to prevent the workflow to fail when all other jobs are skipped."
29 changes: 24 additions & 5 deletions README.md
@@ -1,34 +1,53 @@
<div align="center">

# TorchGAN

**Framework for easy and efficient training of GANs based on Pytorch**

[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Build Status](https://travis-ci.org/torchgan/torchgan.svg?branch=master)](https://travis-ci.org/torchgan/torchgan)
[![Backers on Open Collective](https://opencollective.com/torchgan/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/torchgan/sponsors/badge.svg)](#sponsors) [![Build status](https://ci.appveyor.com/api/projects/status/lqo3bbsew83839c0/branch/master?svg=true)](https://ci.appveyor.com/project/avik-pal/torchgan/branch/master)
[![Downloads](https://pepy.tech/badge/torchgan)](https://pepy.tech/project/torchgan)
[![Downloads](https://pepy.tech/badge/torchgan/month)](https://pepy.tech/project/torchgan/month)
[![Downloads](https://pepy.tech/badge/torchgan/week)](https://pepy.tech/project/torchgan/week)
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)
[![Slack](https://img.shields.io/badge/chat-on%20slack-yellow.svg)](https://join.slack.com/t/torchgan/shared_invite/enQtNDkyMTQ2ODAyMzczLWEyZjc1ZDdmNTc3ZmNiODFmMmY2YjM2OTZmZTRlOTc3YWE5MTliZTBkZTkwNzQ2MDIwZmI0MGRjYjQwYTczMzQ)

[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://torchgan.readthedocs.io/en/stable/)
[![Latest Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://torchgan.readthedocs.io/en/latest/)
[![codecov](https://codecov.io/gh/torchgan/torchgan/branch/master/graph/badge.svg)](https://codecov.io/gh/torchgan/torchgan)
[![Codecov](https://codecov.io/gh/torchgan/torchgan/branch/master/graph/badge.svg)](https://codecov.io/gh/torchgan/torchgan)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/torchgan/torchgan/master)
[![PyPI version](https://badge.fury.io/py/torchgan.svg)](https://badge.fury.io/py/torchgan)
</div>

TorchGAN is a [Pytorch](https://pytorch.org) based framework for designing and developing Generative Adversarial Networks. This framework has been designed to provide building blocks for popular GANs and also to allow customization for cutting edge research. Using TorchGAN's modular structure allows

* Trying out popular GAN models on your dataset.
* Plug in your new Loss Function, new Architecture, etc. with the traditional ones.
* Seamlessly visualize the training with a variety of logging backends.

| System / PyTorch Version | 1.2 | 1.3 | 1.4 | nightly |
| :---: | :---: | :---: | :---: | :---: |
| Linux py3.6 (Travis) | <center>—</center> | <center>—</center> | [![Build Status](https://travis-ci.org/torchgan/torchgan.svg?branch=master)](https://travis-ci.org/torchgan/torchgan) | <center>—</center> |
| Linux py3.6 | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) |
| Linux py3.7 | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) |
| OSX py3.6 | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) |
| OSX py3.7 | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) |
| Windows py3.6 (Appveyor) | <center>—</center> | <center>—</center> | [![Build status](https://ci.appveyor.com/api/projects/status/lqo3bbsew83839c0?svg=true)](https://ci.appveyor.com/project/avik-pal/torchgan) | <center>—</center> |
| Windows py3.6 | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) |
| Windows py3.7 (Appveyor) | <center>—</center> | <center>—</center> | [![Build status](https://ci.appveyor.com/api/projects/status/lqo3bbsew83839c0?svg=true)](https://ci.appveyor.com/project/avik-pal/torchgan) | <center>—</center> |
| Windows py3.7 | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) | ![CI Testing](https://github.com/torchgan/torchgan/workflows/CI%20Testing/badge.svg) |

### Installation

Using pip (for stable release):

```bash
$ pip3 install torchgan
$ pip install torchgan
```

Using pip (for latest master):

```bash
$ pip3 install git+https://github.com/torchgan/torchgan.git
$ pip install git+https://github.com/torchgan/torchgan.git
```

From source:
Expand Down
16 changes: 16 additions & 0 deletions pyproject.toml
@@ -0,0 +1,16 @@
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
5 changes: 3 additions & 2 deletions requirements.txt
@@ -1,4 +1,5 @@
numpy
pillow>=6.2.0
fastprogress==0.1.20
pillow
scipy
torch>=1.2
torchvision>=0.4
41 changes: 39 additions & 2 deletions setup.py
Expand Up @@ -32,9 +32,21 @@ def find_version(*file_paths):
raise RuntimeError("Unable to find version string.")


PATH_ROOT = os.path.dirname(__file__)
VERSION = find_version("torchgan", "__init__.py")

requirements = ["numpy", "pillow>=6.2.0", "fastprogress==0.1.20"]

def load_requirements(path_dir=PATH_ROOT, comment_char='#'):
with open(os.path.join(path_dir, 'requirements.txt'), 'r') as file:
lines = [ln.strip() for ln in file.readlines()]
reqs = []
for ln in lines:
# filer all comments
if comment_char in ln:
ln = ln[:ln.index(comment_char)]
if ln: # if requirement is not empty
reqs.append(ln)
return reqs

setup(
# Metadata
Expand All @@ -48,5 +60,30 @@ def find_version(*file_paths):
# Package info
packages=find_packages(exclude=("test",)),
zip_safe=True,
install_requires=requirements,
install_requires=load_requirements(PATH_ROOT),
long_description=open('README.md', encoding='utf-8').read(),
long_description_content_type='text/markdown',
include_package_data=True,
keywords=['deep learning', 'pytorch', 'GAN', 'AI'],
python_requires='>=3.6',
classifiers=[
'Environment :: Console',
'Natural Language :: English',
# How mature is this project? Common values are
# 3 - Alpha, 4 - Beta, 5 - Production/Stable
'Development Status :: 4 - Beta',
# Indicate who your project is intended for
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Image Recognition',
'Topic :: Scientific/Engineering :: Deep Learning',
# Pick your license as you wish
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
)
9 changes: 2 additions & 7 deletions torchgan/trainer/base_trainer.py
Expand Up @@ -5,7 +5,6 @@

import torch
import torchvision
from fastprogress import master_bar, progress_bar

from ..logging.logger import Logger
from ..losses.loss import DiscriminatorLoss, GeneratorLoss
Expand Down Expand Up @@ -393,18 +392,14 @@ def train(self, data_loader, **kwargs):
for name in self.optimizer_names:
getattr(self, name).zero_grad()

master_bar_iter = master_bar(range(self.start_epoch, self.epochs))
for epoch in master_bar_iter:
for epoch in range(self.start_epoch, self.epochs):

start_time = time.time()
master_bar_iter.first_bar.comment = f"Training Progress"

for model in self.model_names:
getattr(self, model).train()

for data in progress_bar(data_loader, parent=master_bar_iter):

master_bar_iter.child.comment = f"Epoch {epoch+1} Progress"
for data in data_loader:

if type(data) is tuple or type(data) is list:
self.real_inputs = data[0].to(self.device)
Expand Down

0 comments on commit 0bd241a

Please sign in to comment.