Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu16.04

RUN apt-get update && \
apt-get install -y software-properties-common

RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && apt-get install -y \
pkg-config \
python3.6-dev \
python3-pip && \
rm -rf /var/lib/apt/lists/*

RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1

RUN ln -s $(which python3.6) /usr/local/bin/python

RUN pip3 install numpy pkgconfig


WORKDIR /workspace
RUN chmod -R a+w /workspace

# Install coviar
WORKDIR /workspace/pytorch-coviar
COPY pytorch-coviar .
WORKDIR /workspace
COPY install.sh .
RUN chmod +x install.sh && \
./install.sh

# Set environment variables
ENV PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/ffmpeg_build/lib/pkgconfig"
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/ffmpeg_build/lib

WORKDIR /workspace/pytorch-coviar/data_loader
RUN chmod +x install.sh && \
./install.sh

WORKDIR /workspace

# Install Python packages
COPY requirements.txt /
RUN pip3 install --upgrade pip
RUN pip3 install -r /requirements.txt

CMD ["sh", "-c", "tail -f /dev/null"]
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,42 @@ There maybe a slight gap between the performance obtained by this script and the
```

## 3. Requirements
```
PyTorch = 0.3
python >= 3.5
```

## 4. Usage
1) before running `OTCD`, [`CoViAR`](https://github.com/chaoyuaw/pytorch-coviar) needs to be installed. Please click the URL for the usage of `CoViAR`.
- [Docker](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
- [Nvidia-Docker](https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(version-2.0))
- [Docker-Compose](https://pypi.org/project/docker-compose/)

1) down load this repo.
## 4. Quickstart

1) Download this repo
```
git clone https://github.com/liuqk3/OTCD.git
cd OTCD
```
2) download the pretrained model from [BaiduYunPan](https://pan.baidu.com/s/1-Enzek8SQpnr1BY1uzde4w). Then put all models to ```./save```. If you have any problems with the download process, please email me.

3) run the tracker
2) Build docker image
```
sudo docker-compose build
```

3) Download the pretrained model from [BaiduYunPan](https://pan.baidu.com/s/1-Enzek8SQpnr1BY1uzde4w). Then put all models to ```./save```. If you have any problems with the download process, please email me.

4) Download [MOT Challenge dataset](https://motchallenge.net/) and place into a sub directory of OTCD. If placed outside of the OTCD directory, edit the volume mapping in `docker-compose.yml`.

5) When finished start docker container
```
sudo docker-compose up -d
```

6) Enter the container
```
sudo docker exec -it otcd bash
```

7) Start tracker
```
python tracking_on_mot.py --mot_dir path/to/MOT-dataset
```

## 5. Code for training
The training scripts are also published in ```useful_scripts```. You can train all the models by the given scripts.
The training scripts are also published in ```useful_scripts```. You can train all the models by the given scripts.
106 changes: 106 additions & 0 deletions compute_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"""py-motmetrics - metrics for multiple object tracker (MOT) benchmarking.

Christoph Heindl, 2017
https://github.com/cheind/py-motmetrics
"""

import argparse
import glob
import os
import logging
import pickle
import motmetrics as mm
import pandas as pd
from collections import OrderedDict
from pathlib import Path

def parse_args():
parser = argparse.ArgumentParser(description="""
Compute metrics for trackers using MOTChallenge ground-truth data.

Files
-----
All file content, ground truth and test files, have to comply with the
format described in

Milan, Anton, et al.
"Mot16: A benchmark for multi-object tracking."
arXiv preprint arXiv:1603.00831 (2016).
https://motchallenge.net/

Structure
---------

Layout for ground truth data
<GT_ROOT>/<SEQUENCE_1>/gt/gt.txt
<GT_ROOT>/<SEQUENCE_2>/gt/gt.txt
...

Layout for test data
<TEST_ROOT>/<SEQUENCE_1>.txt
<TEST_ROOT>/<SEQUENCE_2>.txt
...

Sequences of ground truth and test will be matched according to the `<SEQUENCE_X>`
string.""", formatter_class=argparse.RawTextHelpFormatter)

parser.add_argument('groundtruths', type=str, help='Directory containing ground truth files.')
parser.add_argument('tests', type=str, help='Directory containing tracker result files')
parser.add_argument('--loglevel', type=str, help='Log level', default='info')
parser.add_argument('--fmt', type=str, help='Data format', default='mot15-2D')
parser.add_argument('--solver', type=str, help='LAP solver to use')
return parser.parse_args()

def compare_dataframes(gts, ts):
accs = []
names = []
for k, tsacc in ts.items():
if k in gts:
logging.info('Comparing {}...'.format(k))
accs.append(mm.utils.compare_to_groundtruth(gts[k], tsacc, 'iou', distth=0.5))
names.append(k)
else:
logging.warning('No ground truth for {}, skipping.'.format(k))

return accs, names

if __name__ == '__main__':

args = parse_args()

loglevel = getattr(logging, args.loglevel.upper(), None)
if not isinstance(loglevel, int):
raise ValueError('Invalid log level: {} '.format(args.loglevel))
logging.basicConfig(level=loglevel, format='%(asctime)s %(levelname)s - %(message)s', datefmt='%I:%M:%S')

if args.solver:
mm.lap.default_solver = args.solver

gtfiles = glob.glob(os.path.join(args.groundtruths, '*/gt/gt.txt'))
tsfiles = [f for f in glob.glob(os.path.join(args.tests, '*.txt')) if not os.path.basename(f).startswith('eval')]

logging.info('Found {} groundtruths and {} test files.'.format(len(gtfiles), len(tsfiles)))
logging.info('Available LAP solvers {}'.format(mm.lap.available_solvers))
logging.info('Default LAP solver \'{}\''.format(mm.lap.default_solver))
logging.info('Loading files.')

gt = OrderedDict([(Path(f).parts[-3], mm.io.loadtxt(f, fmt=args.fmt, min_confidence=1)) for f in gtfiles])
ts = OrderedDict([(os.path.splitext(Path(f).parts[-1])[0], mm.io.loadtxt(f, fmt=args.fmt)) for f in tsfiles])

mh = mm.metrics.create()
accs, names = compare_dataframes(gt, ts)

logging.info('Running metrics')

summary = mh.compute_many(accs, names=names, metrics=mm.metrics.motchallenge_metrics, generate_overall=True)
str_summary = mm.io.render_summary(summary, formatters=mh.formatters, namemap=mm.io.motchallenge_metric_names)
print(str_summary)

# print to text file
with open(os.path.join(args.tests, "mot_metrics.log"), mode="w") as text_file:
print(str_summary, file=text_file)

# save dataframe to pickle file
pickle.dump(summary, open(os.path.join(args.tests, "mot_metrics.pkl"), "wb"))

logging.info('Completed')
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "2.3"

services:

otcd:
container_name: otcd
build: .
runtime: nvidia
environment:
- DISPLAY
ipc: host # for GUI
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw # for GUI access
- .:/workspace
# example for volume mapping if MOt data is outside the OTCD directory
- /home/lukas/mv-tracker/data:/workspace/data
entrypoint: ./docker-entrypoint.sh
command: tail -f /dev/null
7 changes: 7 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e

cd /workspace/lib/model/roi_align && chmod +x install.sh && ./install.sh
cd /workspace/lib/model/nms && chmod +x make.sh && ./make.sh

exec "$@"
92 changes: 92 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

INSTALL_BASE_DIR="$PWD/.."
INSTALL_DIR="$PWD"

echo "Installing module into: $INSTALL_DIR"

# Install build tools
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
wget \
unzip \
build-essential \
cmake \
git \
pkg-config \
autoconf \
automake \
git-core \
python3-dev \
python3-pip \
python3-numpy \
python3-pkgconfig && \
rm -rf /var/lib/apt/lists/*


###############################################################################
#
# FFMPEG
#
###############################################################################

# Install FFMPEG dependencies
apt-get update -qq && \
apt-get -y install \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
texinfo \
zlib1g-dev \
nasm \
yasm \
libx264-dev \
libx265-dev \
libnuma-dev \
libvpx-dev \
libfdk-aac-dev \
libmp3lame-dev \
libopus-dev


# Download FFMPEG source
FFMPEG_VERSION="4.1.3"
mkdir -p "$INSTALL_BASE_DIR"/ffmpeg_sources/ffmpeg "$INSTALL_BASE_DIR"/bin
cd "$INSTALL_BASE_DIR"/ffmpeg_sources
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-"$FFMPEG_VERSION".tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2 -C "$INSTALL_BASE_DIR"/ffmpeg_sources/ffmpeg --strip-components=1
rm -rf "$INSTALL_BASE_DIR"/ffmpeg_sources/ffmpeg-snapshot.tar.bz2
cd "$INSTALL_BASE_DIR"/ffmpeg_sources/ffmpeg

# Compile FFMPEG
cd "$INSTALL_BASE_DIR"/ffmpeg_sources/ffmpeg && \
./configure \
--prefix="$INSTALL_BASE_DIR/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$INSTALL_BASE_DIR/ffmpeg_build/include" \
--extra-ldflags="-L$INSTALL_BASE_DIR/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$INSTALL_BASE_DIR/bin" \
--enable-gpl \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
--enable-pic && \
make -j $(nproc) && \
make install && \
hash -r
Empty file modified lib/make.sh
100644 → 100755
Empty file.
Binary file modified lib/model/nms/_ext/nms/_nms.so
Binary file not shown.
Empty file modified lib/model/nms/make.sh
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions lib/model/nms/src/nms_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ extern THCState *state;
int nms_cuda(THCudaIntTensor *keep_out, THCudaTensor *boxes_host,
THCudaIntTensor *num_out, float nms_overlap_thresh) {

nms_cuda_compute(THCudaIntTensor_data(state, keep_out),
THCudaIntTensor_data(state, num_out),
THCudaTensor_data(state, boxes_host),
boxes_host->size[0],
nms_cuda_compute(THCudaIntTensor_data(state, keep_out),
THCudaIntTensor_data(state, num_out),
THCudaTensor_data(state, boxes_host),
boxes_host->size[0],
boxes_host->size[1],
nms_overlap_thresh);

Expand Down
Binary file modified lib/model/nms/src/nms_cuda_kernel.cu.o
Binary file not shown.
Binary file removed lib/model/psroi_pooling/src/cuda/psroi_pooling.cu.o
Binary file not shown.
Empty file modified lib/model/roi_align/install.sh
100644 → 100755
Empty file.
Binary file removed lib/model/roi_crop/src/roi_crop_cuda_kernel.cu.o
Binary file not shown.
3 changes: 0 additions & 3 deletions lib/model/utils/.gitignore

This file was deleted.

Loading