Tsinghua-Tencent 100K Tutorial

Hello, welcome to the tutorial of Tsinghua-Tencent 100k, in this tutorial, we will show you:

  • How to run our model with TT100K dataset
  • The structure of TT100K
  • How to observe TT100K
  • How to evaluate your result

How to run our model with TT100K dataset

First we need to download and extract the dataset and code from website http://cg.cs.tsinghua.edu.cn/traffic-sign/, Make sure your disk have 100G free space at least.

In [ ]:
mkdir TT100K && cd TT100K
wget http://cg.cs.tsinghua.edu.cn/traffic-sign/data_model_code/data.zip
wget http://cg.cs.tsinghua.edu.cn/traffic-sign/data_model_code/code.zip
unzip data.zip
unzip code.zip

Next, we have to build caffe code.

In [ ]:
cd code/script

Then, we need to build the dataset into the LMDB format, and calculate the image mean for caffe training.

In [ ]:
mkdir -p ../../data/lmdb

Finally, we start the training process.

In [ ]:
../caffe/build/tools/caffe train --solver ../model/solver.prototxt --gpu 0

The training begin! The model converges in 40K iterations, it takes about 3 to 4 days.

The structure of TT100K

Explanation of directories:


  • caffe: caffe code that we used
  • model: our caffe model file
  • script: scripts used in this tutorial.
  • python: some python utils
    • anno_func.py: some useful utils function
    • data_show.ipynb: example of displaying images
    • deployer.ipynb: example of deployer
    • eval_check.ipynb: example of evaluating


  • train: all train pictures
  • test: all test pictures
  • other: some data that exclude from train and test
  • marks: standard traffic sign picture that are used for data agumentation
  • annotations.json: json file which contains the annotations of the pictures
  • results: results of our model and fast-rcnn

How to observe TT100K

In this section, we will show you the overview of this dataset, first we import the neccesery libraries.

In [8]:
cd ../python/
In [9]:
import json
import pylab as pl
import random
import numpy as np
import cv2
import anno_func
%matplotlib inline

Then, we load the json annotation file and list of the test images's id

In [10]:
datadir = "../../data/"

filedir = datadir + "/annotations.json"
ids = open(datadir + "/test/ids.txt").read().splitlines()

annos = json.loads(open(filedir).read())

Let's take a look about annotation json file,

annos has two keys:

In [12]:
[u'imgs', u'types']

annos['types'] contains types we have in TT100K

In [14]:

You can sample an id and visualize the image by using our utils.

In [29]:
imgid = random.sample(ids, 1)[0]
print imgid

imgdata = anno_func.load_img(annos, datadir, imgid)
imgdata_draw = anno_func.draw_all(annos, datadir, imgid, imgdata)
((1106.3541259765625, 977.7344970703125), (18.043243408203125, 20.239809036254883), 122.83193969726562)
<matplotlib.image.AxesImage at 0x7fbee59b8b90>