This repository contains exercises and the project for the Very Deep Learning lecture at the University of Fribourg, Switzerland. Our group consists of:
- Ajayi Jesutofunmi
- Balsiger Fabian
- Hemati Hamed
- Murena Patrick
- Suter Yannick
A TAC-GAN implementation in PyTorch. The original TensorFlow implementation can be found here. Following files were copied from the original implementation:
dataprep_flowers.py
: renamed todata_prep.py
and modified to include the COCO datasetencode_text.py
skipthoughts.py
train.py
: see thetensorflow
directory
The project requires Python 3.5.2.
Install all other requirements by running pip install -r requirements.txt
.
We assume that we store the datasets in a Data
directory in the root directory of this project throughout this data preparation.
Independent of the dataset, the skip-thought vectors need to be downloaded.
-
Download the pre-trained skip-thought vectors model into the directory
Data/skipthoughts
by executing:wget http://www.cs.toronto.edu/~rkiros/models/dictionary.txt wget http://www.cs.toronto.edu/~rkiros/models/utable.npy wget http://www.cs.toronto.edu/~rkiros/models/btable.npy wget http://www.cs.toronto.edu/~rkiros/models/uni_skip.npz wget http://www.cs.toronto.edu/~rkiros/models/uni_skip.npz.pkl wget http://www.cs.toronto.edu/~rkiros/models/bi_skip.npz wget http://www.cs.toronto.edu/~rkiros/models/bi_skip.npz.pkl
-
Adjust the
path_to_models
andpath_to_labels
(lines 23 and 24) inskipthoughts.py
if you use another data directory thanData
. -
Install the required tokenizers with a Python script:
import nltk nltk.download('punkt')
To train the TAC-GAN on the flowers dataset, download the dataset by doing the following.
-
Download the flower images from here. Extract the
102flowers.tgz
file and copy the extractedjpg
folder toData/datasets/flowers
. -
Download the captions from here. Extract the
text_c10
folder and theallclasses.txt
and paste it in theData/datasets/flowers
directory. -
Run the flowers dataset preparation:
python data_prep.py --data_dir=Data --dataset=flowers
This script will create a set of pickled files in the
Data/datasets/flowers
directory which will be used during training.
ATTENTION: The TensorFlow implementation will raise an error when the flowers dataset is prepared with this implementation.
It is necessary to change the names of two pickle files in the Data/datasets/flowers
directory:
flowers_tc.pkl
toflower_tc.pkl
flowers_tv.pkl
toflower_tv.pkl
To train the TAC-GAN on the COCO dataset, download the dataset by doing the following.
-
Download the COCO dataset
-
Extract both archives to the folder
Data/datasets/coco
. -
Rename the folder
train2017
tojpg
. -
Run
make
in the directorypycocotools
. -
Run the COCO dataset preparation:
python data_prep.py --data_dir=Data --dataset=coco
This script will create a set of pickled files in the
Data/datasets/coco
directory which will be used during training.
We perform three experiments with the COCO dataset:
- Full dataset with 80 categories
- 9 animal categories
- replace line 74 in
data_prep.py
withclass_names = ['cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe']
- replace line 74 in
- 10 randomly selected categories
- replace line 74 in
data_prep.py
withclass_names = ['wine glass', 'cup', 'keyboard', 'cat', 'banana', 'surfboard', 'bus', 'truck', 'baseball glove', 'microwave']
- replace line 74 in