Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit 3b1143c

Browse files
committed
fixed some bugs and updated README
1 parent 39bf80d commit 3b1143c

5 files changed

+20
-31
lines changed

README.md

+7-24
Original file line numberDiff line numberDiff line change
@@ -66,44 +66,27 @@ $ wget https://aladdin-eax.inf.cs.cmu.edu/shares/diva_obj_detect_models/models/o
6666
$ tar -zxvf obj_v3_model.tgz
6767
```
6868

69-
2. Run object detection on the test videos
70-
```
71-
$ python obj_detect.py --model_path obj_v3_model --version 3 --video_dir v1-val_testvideos \
72-
--video_lst_file v1-val_testvideos.lst --out_dir test_json_out --frame_gap 1 --visualize \
73-
--vis_path test_vis_out --get_box_feat --box_feat_path test_box_feat_out
74-
```
75-
The object detection output for each frame will be in `test_json_out/` and in COCO format. The visualization frames will be in `test_vis_out/`. The ROI features will be in `test_box_feat_out/`. Remove `--visualize --vis_path test_vis_out` and `--get_box_feat --box_feat_path test_box_feat_out` if you only want the json files.
76-
77-
3. Run object detection & tracking on the test videos
69+
2. Run object detection & tracking on the test videos
7870
```
7971
$ python obj_detect_tracking.py --model_path obj_v3_model --version 3 --video_dir v1-val_testvideos \
80-
--video_lst_file v1-val_testvideos.lst --out_dir test_json_out --frame_gap 1 --get_tracking \
72+
--video_lst_file v1-val_testvideos.lst --frame_gap 1 --get_tracking \
8173
--tracking_dir test_track_out
8274
```
75+
To have the object detection output in COCO json format, add `--out_dir test_json_out `; To have the bounding box visualization, add `--visualize --vis_path test_vis_out`.
76+
To speed it up, try `--frame_gap 8`, and the tracks between detection frames will be linearly interpolated.
8377
The tracking results will be in `test_track_out/` and in MOTChallenge format. To visualize the tracking results:
8478
```
85-
$ ls $PWD/v1-val_testvideos/* > v1-val_testvideos.abs.lst
86-
$ python get_frames_resize.py v1-val_testvideos.abs.lst v1-val_testvideos_frames/ --use_2level
87-
$ cd test_track_out/VIRAT_S_000205_05_001092_001124.mp4
88-
$ ls Person > Person.lst; ls Vehicle > Vehicle.lst
89-
$ python ../../track_to_json.py Vehicle Vehicle.lst Vehicle Vehicle_json
90-
$ python ../../track_to_json.py Person Person.lst Person Person_json
91-
$ python ../../vis_json.py Person.lst ../../v1-val_testvideos_frames/ Person_json/ Person_vis
92-
$ python ../../vis_json.py Vehicle.lst ../../v1-val_testvideos_frames/ Vehicle_json/ Vehicle_vis
93-
$ ffmpeg -framerate 30 -i Vehicle_vis/VIRAT_S_000205_05_001092_001124/VIRAT_S_000205_05_001092_001124_F_%08d.jpg Vehicle_vis_video.mp4
94-
$ ffmpeg -framerate 30 -i Person_vis/VIRAT_S_000205_05_001092_001124/VIRAT_S_000205_05_001092_001124_F_%08d.jpg Person_vis_video.mp4
95-
96-
# or you could put "Person/Vehicle" visualization into the same video
79+
# Put "Person/Vehicle" tracks visualization into the same video
9780
$ ls $PWD/v1-val_testvideos/* > v1-val_testvideos.abs.lst
9881
$ python get_frames_resize.py v1-val_testvideos.abs.lst v1-val_testvideos_frames/ --use_2level
9982
$ python tracks_to_json.py test_track_out/ v1-val_testvideos.abs.lst test_track_out_json
10083
$ python vis_json.py v1-val_testvideos.abs.lst v1-val_testvideos_frames/ test_track_out_json/ test_track_out_vis
10184
# then use ffmpeg to make videos
102-
85+
$ ffmpeg -framerate 30 -i test_track_out_vis/VIRAT_S_000205_05_001092_001124/VIRAT_S_000205_05_001092_001124_F_%08d.jpg vis_video.mp4
10386
```
10487
Now you have the tracking visualization videos for both "Person" and "Vehicle" class.
10588

106-
4. You can also run both inferencing with frozen graph (See [this](SPEED.md) for instructions of how to pack the model). Change `--model_path obj_v3.pb` and add `--is_load_from_pb`. It is about 30% faster.
89+
3. You can also run inferencing with frozen graph (See [this](SPEED.md) for instructions of how to pack the model). Change `--model_path obj_v3.pb` and add `--is_load_from_pb`. It is about 30% faster. For running on [MEVA](http://mevadata.org/) dataset (avi videos & indoor scenes) or with [EfficientDet](https://github.com/google/automl/tree/master/efficientdet) models, see examples [here](COMMANDS.md).
10790

10891
## Models
10992
These are the models you can use for inferencing. The original ActEv annotations can be downloaded from [here](https://next.cs.cmu.edu/data/actev-v1-drop4-yaml.tgz). I will add instruction for training and testing if requested. Click to download each model.

obj_detect_tracking.py

+1
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ def log_gpu_util(interval, gpuid_range):
777777
vis_file = os.path.join(vis_path,
778778
"%s_F_%08d.jpg" % (videoname, vis_count))
779779
cv2.imwrite(vis_file, newim)
780+
vis_count += 1
780781

781782
cur_frame += 1
782783

track_to_json.py

100644100755
+3-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141

4242
box = [float(left), float(top), float(width), float(height)]
4343

44-
if not data.has_key(frameIdx):
44+
#if not data.has_key(frameIdx):
45+
if not frameIdx in data:
4546
data[frameIdx] = []
4647
data[frameIdx].append({
4748
"category_id": targetClass2id[args.cat_name],
@@ -53,7 +54,7 @@
5354
})
5455

5556
for frameIndex in data:
56-
57+
5758
annofile = os.path.join(args.despath, "%s_F_%08d.json"%(videoname, frameIndex))
5859

5960
with open(annofile, "w") as f:

tracks_to_json.py

100644100755
+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444

4545
box = [float(left), float(top), float(width), float(height)]
4646

47-
if not data.has_key(frameIdx):
47+
#if not data.has_key(frameIdx):
48+
if not frameIdx in data:
4849
data[frameIdx] = []
4950
data[frameIdx].append({
5051
"category_id": targetClass2id[cat_name],
@@ -56,7 +57,7 @@
5657
})
5758

5859
for frameIndex in data:
59-
60+
6061
annofile = os.path.join(args.despath, "%s_F_%08d.json"%(os.path.splitext(videoname)[0], frameIndex))
6162

6263
with open(annofile, "w") as f:

vis_json.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,13 @@ def draw_boxes(im, boxes, labels=None, colors=None, font_scale=0.6,
251251
box = one['bbox'] # [x, y, w, h]
252252
box = [box[0], box[1], box[0] + box[2], box[1] + box[3]]
253253
boxes.append(box)
254-
if one.has_key("trackId"):
254+
#if one.has_key("trackId"):
255+
if "trackId" not in one:
255256
trackId = int(one['trackId'])
256257
color_key = (trackId, one['cat_name'])
257258
labels.append("%s: #%s"%(one['cat_name'], trackId))
258-
if not color_assign.has_key(color_key):
259+
#if not color_assign.has_key(color_key):
260+
if color_key not in color_assign:
259261
this_color = color_queue.pop()
260262
color_assign[color_key] = this_color
261263
# recycle it
@@ -266,7 +268,8 @@ def draw_boxes(im, boxes, labels=None, colors=None, font_scale=0.6,
266268
# no trackId, just visualize the boxes
267269
cat_name = one['cat_name']
268270
labels.append("%s: %.2f"%(cat_name, float(one['score'])))
269-
if not color_assign.has_key(cat_name):
271+
#if not color_assign.has_key(cat_name):
272+
if cat_name not in color_assign:
270273
this_color = color_queue.pop()
271274
color_assign[cat_name] = this_color
272275
# recycle it

0 commit comments

Comments
 (0)