Skip to content

Commit 4a60a1f

Browse files
committed
full training code
1 parent 9c8f17e commit 4a60a1f

18 files changed

+730
-1
lines changed

.gitignore

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
98+
__pypackages__/
99+
100+
# Celery stuff
101+
celerybeat-schedule
102+
celerybeat.pid
103+
104+
# SageMath parsed files
105+
*.sage.py
106+
107+
# Environments
108+
.env
109+
.venv
110+
env/
111+
venv/
112+
ENV/
113+
env.bak/
114+
venv.bak/
115+
116+
# Spyder project settings
117+
.spyderproject
118+
.spyproject
119+
120+
# Rope project settings
121+
.ropeproject
122+
123+
# mkdocs documentation
124+
/site
125+
126+
# mypy
127+
.mypy_cache/
128+
.dmypy.json
129+
dmypy.json
130+
131+
# Pyre type checker
132+
.pyre/
133+
134+
# pytype static type analyzer
135+
.pytype/
136+
137+
# Cython debug symbols
138+
cython_debug/
139+
140+
# Manual
141+
.vscode
142+
**/*[.jpg,.jpeg,.png,.JPG,.JPEG,.PNG]
143+
!reports/figures/*[.jpg,.jpeg,.png,.JPG,.JPEG,.PNG]
144+
**/__pycache__
145+
146+
#####
147+
!.gitkeep
148+
!.gitignore
149+
150+
data
151+
logs

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
11
# PYTORCH GAN
22

3+
## Usage
34

4-
### work in progress
5+
- to run training `cli.py`
6+
7+
optional arguments:
8+
-h, --help show this help message and exit
9+
--lr LR learning rate, deafault 2e-4
10+
--epochs EPOCHS training epochs, default 100
11+
--batchsz BATCHSZ batch size, default 64
12+
--imagesz IMAGESZ image size, default 64
13+
--imagech IMAGECH image channel, default 3
14+
--datafl DATAFL data folder, default 'data/raw'
15+
--noisedim NOISEDIM input noise dimension, default 128
16+
--disfea DISFEA discriminator features, default 64
17+
--genfea GENFEA generator features, default 64
18+
--log logs, type_action: default true
19+
20+
- to generate fake samples: ...
21+
## Report
22+
23+
After `epochs: 20` and with `batch-size: 64`
24+
25+
+ Loss Discriminator
26+
27+
![Loss_Discriminator](reports/figures/loss-discriminator.svg?style=center "normal xray activation map")
28+
29+
+ Loss Generator
30+
31+
![Loss_Generator](reports/figures/loss-generator.svg?style=center "normal xray activation map")
32+
33+
+ Fake
34+
35+
![Fake_Sample](reports/figures/sample-fake.png?style=center "normal xray activation map")
36+
37+
+ Real
38+
39+
![Real_Sample](reports/figures/sample-real.png?style=center "normal xray activation map")
40+
41+
<!-- <p align="center">
42+
<img width="250" height="300" src="resources/logo.png">
43+
</p> -->

cli.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import argparse
4+
import os.path
5+
6+
from trainer import main as train
7+
8+
def sanityCheck(args):
9+
10+
train(args=args)
11+
12+
13+
if __name__ == "__main__":
14+
15+
parser = argparse.ArgumentParser(description='commands line arguments')
16+
17+
parser.add_argument("--lr", type=int, default=2e-4, required=False, help="learning rate, deafault 2e-4")
18+
parser.add_argument( "--epochs", type=int, default=100, required=False, help="training epochs, default 100")
19+
parser.add_argument( "--batchsz", type=int, default=64, required=False, help="batch size, default 64")
20+
21+
parser.add_argument( "--imagesz", type=int, default=64, required=False, help="image size, default 64")
22+
parser.add_argument( "--imagech", type=int, default=3, required=False, help="image channel, default 3")
23+
parser.add_argument( "--datafl", type=str, default='data/raw', required=False, help="data folder, default \'data/raw\'")
24+
25+
parser.add_argument( "--noisedim", type=int, default=128, required=False, help="input noise dimension, default 128")
26+
parser.add_argument( "--disfea", type=int, default=64, required=False, help="discriminator features, default 64")
27+
parser.add_argument( "--genfea", type=int, default=64, required=False, help="generator features, default 64")
28+
29+
parser.add_argument ( '--log', action = 'store_false', help="logs, default true")
30+
31+
args = parser.parse_args()
32+
33+
sanityCheck(args=args)
34+
35+

evaluator.py

Whitespace-only changes.

models/.gitkeep

Whitespace-only changes.

reports/architecture.csv

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Model,Size,Parameters,Depth
2+
Xception,88 MB,22910480,126
3+
VGG16,528 MB,138357544,23
4+
VGG19,549 MB,143667240,26
5+
ResNet50,98 MB,25636712,-
6+
ResNet101,171 MB,44707176,-
7+
ResNet152,232 MB,60419944,-
8+
ResNet50V2,98 MB,25613800,-
9+
ResNet101V2,171 MB,44675560,-
10+
ResNet152V2,232 MB,60380648,-
11+
InceptionV3,92 MB,23851784,159
12+
InceptionResNetV2,215 MB,55873736,572
13+
MobileNet,16 MB,4253864,88
14+
MobileNetV2,14 MB,3538984,88

reports/figures/.gitkeep

Whitespace-only changes.

reports/figures/loss-discriminator.svg

Lines changed: 1 addition & 0 deletions
Loading

reports/figures/loss-generator.svg

Lines changed: 1 addition & 0 deletions
Loading

reports/figures/sample-fake.png

686 KB
Loading

reports/figures/sample-real.png

641 KB
Loading

src/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)