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.pyand modified to include the COCO datasetencode_text.pyskipthoughts.pytrain.py: see thetensorflowdirectory
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/skipthoughtsby 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_modelsandpath_to_labels(lines 23 and 24) inskipthoughts.pyif 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.tgzfile and copy the extractedjpgfolder toData/datasets/flowers. -
Download the captions from here. Extract the
text_c10folder and theallclasses.txtand paste it in theData/datasets/flowersdirectory. -
Run the flowers dataset preparation:
python data_prep.py --data_dir=Data --dataset=flowersThis script will create a set of pickled files in the
Data/datasets/flowersdirectory 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.pkltoflower_tc.pklflowers_tv.pkltoflower_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
train2017tojpg. -
Run
makein the directorypycocotools. -
Run the COCO dataset preparation:
python data_prep.py --data_dir=Data --dataset=cocoThis script will create a set of pickled files in the
Data/datasets/cocodirectory 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.pywithclass_names = ['cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe']
- replace line 74 in
- 10 randomly selected categories
- replace line 74 in
data_prep.pywithclass_names = ['wine glass', 'cup', 'keyboard', 'cat', 'banana', 'surfboard', 'bus', 'truck', 'baseball glove', 'microwave']
- replace line 74 in