The scripts here are inspired by C3D Model for Keras
gist, but specifically for Keras + TensorFlow (not Theano-backend).
To reproduce results:
- Run a script that does everything:
bash do_everything.sh
OR, build a docker image, which will do all the steps of replication during the build:
docker build -t c3d-keras .
OR, run each of these steps:
- Download pretrained model:
bash models/get_weights_and_mean.sh
- Download sport1mil labels:
bash sports1m/get_labels.sh
- Download facebook/C3D
caffe.proto
file for conversion from caffe to Keras:wget https://raw.githubusercontent.com/facebook/C3D/master/C3D-v1.0/src/caffe/proto/caffe.proto
- Install protobuf per instruction in https://github.com/google/protobuf. In Ubuntu,
sudo apt-get install protobuf-compiler
will do. - Compile the caffe.proto file for python:
protoc --python_out=. caffe.proto
- Make sure the default keras config (in
~/.keras/keras.json
) has:tf
image_dim_ordering, andtensorflow
backend. - Convert the pre-trained model from Caffe format to Keras:
python convert_caffe_model.py
- Download test video:
bash download_test_video.sh
- Run test:
python test_model.py
Known to work with the following python packages:
- Keras==2.0.0
- tensorflow==0.12.1
- h5py==2.6.0
- numpy==1.12.0
- cv2==3.1.0
- pydot==1.1.0
- graphviz
Some basic command-line tools:
A following classification probability plot is expected (saved as probabilities.png
). A peak at 367th class (probability = 71%) corresponds to basketball label.
The top 5 labels will also be reported, and should look something like:
Position of maximum probability: 367
Maximum probability: 0.57953
Corresponding label: basketball
Top 5 probabilities and labels:
basketball: 0.57953
volleyball: 0.14435
streetball: 0.06718
freestyle wrestling: 0.03323
greco-roman wrestling: 0.03293
Feel free to contact Chuck Cho (cycho at axon.com) for any comment or feedback.
- Source code: 2-clause BSD.
- Data: various Creative Commons licenses. See LICENSE.md for details.