-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeepsortv4.py
72 lines (53 loc) · 2.28 KB
/
deepsortv4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
"""Deepsortv4.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1gKViQZSB-ECwkFQbF4VPIaO_kGf-rBge
"""
# Commented out IPython magic to ensure Python compatibility.
#mount drive
# %cd ..
from google.colab import drive
drive.mount('/content/gdrive')
# this creates a symbolic link so that now the path /content/gdrive/My\ Drive/ is equal to /mydrive
!ln -s /content/gdrive/My\ Drive/ /mydrive
# list the contents of /mydrive
!ls /mydrive
#Navigate to /mydrive/YOLOV4_Det
# %cd /mydrive/yolov4-deepsort
!git clone https://github.com/theAIGuysCode/yolov4-deepsort
## yolov4-tiny
!python save_model.py --weights ./data/yolov4-custom_best.weights --output ./checkpoints/yolov4-416 --input_size 416 --model yolov4
# run DeepSort with YOLOv4 Object Detections as backbone (enable --info flag to see info about tracked objects)
!python object_tracker.py --video ./data/video/crowded.mp4 --output ./outputs/tracker.avi --model yolov4 --dont_show --info
# define helper function to display videos
import io
from IPython.display import HTML
from base64 import b64encode
def show_video(file_name, width=640):
# show resulting deepsort video
mp4 = open(file_name,'rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
return HTML("""
<video width="{0}" controls>
<source src="{1}" type="video/mp4">
</video>
""".format(width, data_url))
!pwd
# Commented out IPython magic to ensure Python compatibility.
# convert resulting video from avi to mp4 file format
import os
path_video = os.path.join("outputs","tracker.avi")
# %cd outputs/
!ffmpeg -y -loglevel panic -i tracker.avi output.mp4
# %cd ..
# output object tracking video
path_output = os.path.join("outputs","output.mp4")
show_video(path_output, width=960)
!pwd
!git clone https://github.com/JonathonLuiten/TrackEval.git
# Commented out IPython magic to ensure Python compatibility.
# %cd TrackEval/
!unzip data.zip
!python scripts/run_mot_challenge.py --BENCHMARK MOT20 --SPLIT_TO_EVAL train --TRACKERS_TO_EVAL MPNTrack --METRICS CLEAR Identity --USE_PARALLEL False --NUM_PARALLEL_CORES 1
!python scripts/run_mot_challenge.py --BENCHMARK MOT20 --TRACKERS_TO_EVAL LPC_MOT --METRICS CLEAR Identity --USE_PARALLEL False --NUM_PARALLEL_CORES 1