Skip to content

Commit 42286db

Browse files
committed
Clean up the mess - (Eg. of a bad commit message)
1 parent 2f2a8c0 commit 42286db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+289
-167613
lines changed

.gitignore

Lines changed: 173 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,174 @@
1-
backup
2-
output
3-
code/*.pyc
4-
code/miscc/*.pyc
1+
# Created by https://www.gitignore.io/api/macos,python,visualstudiocode
2+
# Edit at https://www.gitignore.io/?templates=macos,python,visualstudiocode
3+
4+
### macOS ###
5+
# General
56
.DS_Store
6-
.idea/
7+
.AppleDouble
8+
.LSOverride
9+
10+
# Icon must end with two \r
11+
Icon
12+
13+
# Thumbnails
14+
._*
15+
16+
# Files that might appear in the root of a volume
17+
.DocumentRevisions-V100
18+
.fseventsd
19+
.Spotlight-V100
20+
.TemporaryItems
21+
.Trashes
22+
.VolumeIcon.icns
23+
.com.apple.timemachine.donotpresent
24+
25+
# Directories potentially created on remote AFP share
26+
.AppleDB
27+
.AppleDesktop
28+
Network Trash Folder
29+
Temporary Items
30+
.apdisk
31+
32+
### Python ###
33+
# Byte-compiled / optimized / DLL files
34+
__pycache__/
35+
*.py[cod]
36+
*$py.class
37+
38+
# C extensions
39+
*.so
40+
41+
# Distribution / packaging
42+
.Python
43+
build/
44+
develop-eggs/
45+
dist/
46+
downloads/
47+
eggs/
48+
.eggs/
49+
lib/
50+
lib64/
51+
parts/
52+
sdist/
53+
var/
54+
wheels/
55+
pip-wheel-metadata/
56+
share/python-wheels/
57+
*.egg-info/
58+
.installed.cfg
59+
*.egg
60+
MANIFEST
61+
62+
# PyInstaller
63+
# Usually these files are written by a python script from a template
64+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
65+
*.manifest
66+
*.spec
67+
68+
# Installer logs
69+
pip-log.txt
70+
pip-delete-this-directory.txt
71+
72+
# Unit test / coverage reports
73+
htmlcov/
74+
.tox/
75+
.nox/
76+
.coverage
77+
.coverage.*
78+
.cache
79+
nosetests.xml
80+
coverage.xml
81+
*.cover
82+
.hypothesis/
83+
.pytest_cache/
84+
85+
# Translations
86+
*.mo
87+
*.pot
88+
89+
# Django stuff:
90+
*.log
91+
local_settings.py
92+
db.sqlite3
93+
94+
# Flask stuff:
95+
instance/
96+
.webassets-cache
97+
98+
# Scrapy stuff:
99+
.scrapy
100+
101+
# Sphinx documentation
102+
docs/_build/
103+
104+
# PyBuilder
105+
target/
106+
107+
# Jupyter Notebook
108+
.ipynb_checkpoints
109+
110+
# IPython
111+
profile_default/
112+
ipython_config.py
113+
114+
# pyenv
115+
.python-version
116+
117+
# pipenv
118+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
119+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
120+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
121+
# install all needed dependencies.
122+
#Pipfile.lock
123+
124+
# celery beat schedule file
125+
celerybeat-schedule
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
### VisualStudioCode ###
158+
.vscode/*
159+
!.vscode/settings.json
160+
!.vscode/tasks.json
161+
!.vscode/launch.json
162+
!.vscode/extensions.json
163+
164+
### VisualStudioCode Patch ###
165+
# Ignore all local history of files
166+
.history
167+
168+
# End of https://www.gitignore.io/api/macos,python,visualstudiocode
169+
170+
# Folders
171+
output/*
172+
DAMSMencoders/coco/*
173+
models/*
174+
data/*

DAMSMencoders/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

project_folder/GlobalAttention.py renamed to GlobalAttention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def func_attention(query, context, gamma1):
4545
# Get attention
4646
# (batch x sourceL x ndf)(batch x ndf x queryL)
4747
# -->batch x sourceL x queryL
48-
attn = torch.bmm(contextT, query) # Eq. (7) in AttnGAN paper
48+
attn = torch.bmm(contextT, query) # Eq. (7) in AttnGAN paper
4949
# --> batch*sourceL x queryL
5050
attn = attn.view(batch_size*sourceL, queryL)
5151
attn = nn.Softmax()(attn) # Eq. (8)

README.md

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
**First things first**
2-
This repo is a convenient clone of AttnGAN by MSFT Research. You can find the original repo at [here](https://github.com/taoxugit/AttnGAN.git).
2+
This repo is a convenient clone of AttnGAN by MSFT Research. You can find the original repo at [here](https://github.com/taoxugit/AttnGAN.git).
3+
4+
AttnGAN original repo contains the training and testing code. But this repo is solely intended to use for generating images from text using MSCOCO pretrained weights.
35

46
# AttnGAN
57

@@ -9,11 +11,11 @@ with Attentional Generative Adversarial Networks](http://openaccess.thecvf.com/c
911
<img src="framework.png" width="900px" height="350px"/>
1012

1113

12-
### Python version
14+
**Python version**
1315

1416
`python 2.7`
1517

16-
### Dependencies
18+
**Dependencies**
1719

1820
- `pytorch`
1921
- `python-dateutil`
@@ -23,52 +25,27 @@ with Attentional Generative Adversarial Networks](http://openaccess.thecvf.com/c
2325
- `nltk`
2426
- `scikit-image`
2527

26-
27-
**Data**
28-
29-
1. Download our preprocessed metadata for [birds](https://drive.google.com/open?id=1O_LtUP9sch09QH3s_EBAgLEctBQ5JBSJ) or [coco](https://drive.google.com/open?id=1rSnbIGNDGZeHlsUlLdahj0RJ9oo6lgH9) and save them to `data/`
30-
2. Download the [birds](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html) image data. Extract them to `data/birds/`
31-
3. Download [coco](http://cocodataset.org/#download) dataset and extract the images to `data/coco/`
32-
33-
34-
**Training**
35-
- Pre-train DAMSM models:
36-
- For bird dataset: `python pretrain_DAMSM.py --cfg cfg/DAMSM/bird.yml --gpu 0`
37-
- For coco dataset: `python pretrain_DAMSM.py --cfg cfg/DAMSM/coco.yml --gpu 1`
38-
39-
- Train AttnGAN models:
40-
- For bird dataset: `python main.py --cfg cfg/bird_attn2.yml --gpu 2`
41-
- For coco dataset: `python main.py --cfg cfg/coco_attn2.yml --gpu 3`
42-
28+
**YML files**
4329
- `*.yml` files are example configuration files for training/evaluation our models.
4430

4531

4632
**Pretrained Model**
47-
- [DAMSM for bird](https://drive.google.com/open?id=1GNUKjVeyWYBJ8hEU-yrfYQpDOkxEyP3V). Download and save it to `DAMSMencoders/`
48-
- [DAMSM for coco](https://drive.google.com/open?id=1zIrXCE9F6yfbEJIbNP5-YrEe2pZcPSGJ). Download and save it to `DAMSMencoders/`
49-
- [AttnGAN for bird](https://drive.google.com/open?id=1lqNG75suOuR_8gjoEPYNp8VyT_ufPPig). Download and save it to `models/`
33+
- [DAMSM for coco](https://drive.google.com/open?id=1zIrXCE9F6yfbEJIbNP5-YrEe2pZcPSGJ). Download and save it to `DAMSMencoders/coco/`
5034
- [AttnGAN for coco](https://drive.google.com/open?id=1i9Xkg9nU74RAvkcqKE-rJYhjvzKAMnCi). Download and save it to `models/`
5135

52-
- [AttnDCGAN for bird](https://drive.google.com/open?id=19TG0JUoXurxsmZLaJ82Yo6O0UJ6aDBpg). Download and save it to `models/`
53-
- This is an variant of AttnGAN which applies the propsoed attention mechanisms to DCGAN framework.
54-
55-
**Sampling**
56-
- Run `python main.py --cfg cfg/eval_bird.yml --gpu 1` to generate examples from captions in files listed in "./data/birds/example_filenames.txt". Results are saved to `DAMSMencoders/`.
57-
- Change the `eval_*.yml` files to generate images from other pre-trained models.
58-
- Input your own sentence in "./data/birds/example_captions.txt" if you wannt to generate images from customized sentences.
59-
60-
**Validation**
61-
- To generate images for all captions in the validation dataset, change B_VALIDATION to True in the eval_*.yml. and then run `python main.py --cfg cfg/eval_bird.yml --gpu 1`
62-
- We compute inception score for models trained on birds using [StackGAN-inception-model](https://github.com/hanzhanggit/StackGAN-inception-model).
63-
- We compute inception score for models trained on coco using [improved-gan/inception_score](https://github.com/openai/improved-gan/tree/master/inception_score).
36+
**Setup script**
6437

38+
Run the following script for setting up the dependencies.
6539

66-
**Examples generated by AttnGAN [[Blog]](https://blogs.microsoft.com/ai/drawing-ai/)**
67-
68-
bird example | coco example
69-
:-------------------------:|:-------------------------:
70-
![](https://github.com/taoxugit/AttnGAN/blob/master/example_bird.png) | ![](https://github.com/taoxugit/AttnGAN/blob/master/example_coco.png)
40+
```
41+
./setup.sh
42+
```
7143

44+
**Sampling**
45+
- Run the command from project folder.
46+
```
47+
python2 gen_art.py --gpu 0 --input_text "Mary had a little lamb" --data_dir data/coco --model_path models/coco_AttnGAN2.pth --textencoder_path DAMSMencoders/coco/text_encoder100.pth --output_dir output`
48+
```
49+
- Output will be stored into `output_dir` folder.
50+
- Change the `eval_*.yml` files to generate images from other pre-trained models. Default config file is `cfg/eval_coco.yml`.
7251

73-
### Creating an API
74-
[Evaluation code](eval) embedded into a callable containerized API is included in the `eval\` folder.
File renamed without changes.

code/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)