Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qdtrack #183

Merged
merged 45 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
57ff355
perfect lane detection config
mageofboy Sep 5, 2020
fd40877
python formatting
mageofboy Sep 5, 2020
c264290
add all lane
mageofboy Sep 19, 2020
e6edf81
lint
mageofboy Sep 19, 2020
1680e01
more lint
mageofboy Sep 19, 2020
d4da9f5
...
mageofboy Sep 19, 2020
5fc8be1
more linting
mageofboy Sep 19, 2020
e7fe4e5
pr comments
mageofboy Sep 19, 2020
021e20d
lint
mageofboy Sep 19, 2020
c54a88d
lint
mageofboy Sep 19, 2020
5a2a550
fix to get all lane
mageofboy Sep 22, 2020
14581b8
merge confl
mageofboy Sep 22, 2020
61d85da
merge
mageofboy Oct 23, 2020
f4ad20f
updates
mageofboy Nov 17, 2020
d28e735
Merge branch 'master' of https://github.com/mageofboy/pylot into updates
mageofboy Nov 17, 2020
25d4b7d
lint
mageofboy Nov 17, 2020
14d7d14
Merge pull request #1 from mageofboy/updates
mageofboy Nov 17, 2020
f226257
update data process
mageofboy Nov 23, 2020
0ea61c7
Merge branch 'master' of https://github.com/mageofboy/pylot into updates
mageofboy Nov 23, 2020
a0b771c
Merge branch 'master' of https://github.com/erdos-project/pylot into …
mageofboy Nov 23, 2020
ee9b532
fixed data generation
mageofboy Dec 12, 2020
a6cac05
Merge branch 'master' of https://github.com/erdos-project/pylot
mageofboy Dec 12, 2020
503dc42
linting
mageofboy Dec 12, 2020
fa035c1
Merge pull request #2 from mageofboy/updates
mageofboy Dec 12, 2020
6d3f771
Merge branch 'master' of https://github.com/mageofboy/pylot
mageofboy Dec 12, 2020
b235b95
lint
mageofboy Dec 12, 2020
7b9624f
lint
mageofboy Dec 12, 2020
4b2ef4d
merge conf
mageofboy Apr 14, 2021
cba1d1a
start
mageofboy Apr 16, 2021
eb503be
model working, need fix operator
mageofboy Apr 23, 2021
9998488
add lanenet
mageofboy Apr 23, 2021
c8d89e5
start
mageofboy Apr 16, 2021
3dcfbfb
model working, need fix operator
mageofboy Apr 23, 2021
c971388
add lanenet
mageofboy Apr 23, 2021
cb69924
working versison of qd track op
mageofboy Apr 30, 2021
fcde4aa
update frame_id, add timing, id to int
mageofboy May 2, 2021
e0d12f3
qd oper
mageofboy Jul 17, 2021
6418774
revert conf
mageofboy Jul 17, 2021
66b361c
revise alg
mageofboy Jul 17, 2021
16b3e46
lint
mageofboy Jul 17, 2021
a6ba4f5
lint
mageofboy Jul 17, 2021
aaf9002
lint
mageofboy Jul 17, 2021
b4c756a
Update tracking.conf
mageofboy Jul 18, 2021
2c9bcbd
remove lanenet frm pr
mageofboy Jul 18, 2021
2b76f41
rm lanenet postprocess, readd process
mageofboy Jul 18, 2021
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
14 changes: 14 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ mkdir -p tracking/center_track ; cd tracking/center_track
# COCO model
~/.local/bin/gdown https://drive.google.com/uc?id=1tJCEJmdtYIh8VuN8CClGNws3YO7QGd40

###### Download QDTrack models ######
cd $PYLOT_HOME/dependencies/models
mkdir -p tracking/qd_track ; cd tracking/qd_track
~/.local/bin/gdown https://drive.google.com/uc?id=1YNAQgd8rMqqEG-fRj3VWlO4G5kdwJbxz

##### Download AnyNet depth estimation models #####
echo "[x] Downloading the depth estimation models..."
cd $PYLOT_HOME/dependencies/models
Expand Down Expand Up @@ -141,6 +146,15 @@ sudo apt-get install llvm-9
export LLVM_CONFIG=/usr/bin/llvm-config-9
python3 setup.py build develop --user

###### Install QDTrack ######
cd $PYLOT_HOME/dependencies/
git clone https://github.com/mageofboy/qdtrack.git
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
python3 setup.py develop #need to add mmcv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How reliable is mmdetection's installation? Did it work out of the box for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately it is not reliable and installation depends on torch and cuda version

cd $PYLOT_HOME/dependencies/qdtrack
python3 setup.py develop

##### Download the Lanenet code #####
echo "[x] Cloning the lanenet lane detection code..."
cd $PYLOT_HOME/dependencies/
Expand Down
5 changes: 5 additions & 0 deletions pylot/component_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ def add_obstacle_tracking(center_camera_stream,
obstacles_wo_history_tracking_stream = \
pylot.operator_creator.add_center_track_tracking(
center_camera_stream, center_camera_setup)
elif FLAGS.tracker_type == 'qd_track':
logger.debug('Using QDTrack obstacle tracker...')
obstacles_wo_history_tracking_stream = \
pylot.operator_creator.add_qd_track_tracking(
center_camera_stream, center_camera_setup)
else:
logger.debug('Using obstacle tracker...')
obstacles_wo_history_tracking_stream = \
Expand Down
7 changes: 4 additions & 3 deletions pylot/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
'True to enable obstacle tracking operator')
flags.DEFINE_bool('perfect_obstacle_tracking', False,
'True to enable perfect obstacle tracking')
flags.DEFINE_enum('tracker_type', 'sort',
['da_siam_rpn', 'deep_sort', 'sort', 'center_track'],
'Sets which obstacle tracker to use')
flags.DEFINE_enum(
'tracker_type', 'sort',
['da_siam_rpn', 'deep_sort', 'sort', 'center_track', 'qd_track'],
'Sets which obstacle tracker to use')
flags.DEFINE_bool('lane_detection', False, 'True to enable lane detection')
flags.DEFINE_bool('perfect_lane_detection', False,
'True to enable perfect lane detection')
Expand Down
13 changes: 13 additions & 0 deletions pylot/operator_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@ def add_center_track_tracking(bgr_camera_stream,
return obstacle_tracking_stream


def add_qd_track_tracking(bgr_camera_stream, camera_setup, name='qd_track'):
from pylot.perception.tracking.qd_track_operator import \
QdTrackOperator
op_config = erdos.OperatorConfig(name='qd_track_operator',
log_file_name=FLAGS.log_file_name,
csv_log_file_name=FLAGS.csv_log_file_name,
profile_file_name=FLAGS.profile_file_name)
[obstacle_tracking_stream] = erdos.connect(QdTrackOperator, op_config,
[bgr_camera_stream], FLAGS,
camera_setup)
return obstacle_tracking_stream


def add_tracking_evaluation(obstacle_tracking_stream,
ground_obstacles_stream,
evaluate_timely=False,
Expand Down
1 change: 0 additions & 1 deletion pylot/perception/detection/lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy as np

from pylot.utils import Location, Rotation, Transform, Vector3D

from shapely.geometry import Point
from shapely.geometry.polygon import Polygon

Expand Down
9 changes: 9 additions & 0 deletions pylot/perception/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
['kitti_tracking', 'coco', 'mot', 'nuscenes'],
'CenterTrack available models')

# QDTrack tracking flags.
flags.DEFINE_string(
'qd_track_model_path', 'dependencies/models/tracking/qd_track/' +
'qdtrack-frcnn_r50_fpn_12e_bdd100k-13328aed.pth', 'Path to the model')
flags.DEFINE_string(
'qd_track_config_path',
'dependencies/qdtrack/configs/qdtrack-frcnn_r50_fpn_12e_bdd100k.py',
'Path to the model')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is the Path to the model configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, it's the qd track model path but it's currently the path to the bdd model, rather than the waymo model


# Lane detection flags.
flags.DEFINE_float('lane_detection_gpu_memory_fraction', 0.3,
'GPU memory fraction allocated to Lanenet')
Expand Down
74 changes: 74 additions & 0 deletions pylot/perception/tracking/qd_track_operator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import time

import erdos

from pylot.perception.detection.obstacle import Obstacle
from pylot.perception.detection.utils import BoundingBox2D, \
OBSTACLE_LABELS
from pylot.perception.messages import ObstaclesMessage


class QdTrackOperator(erdos.Operator):
def __init__(self, camera_stream, obstacle_tracking_stream, flags,
camera_setup):
from qdtrack.apis import init_model

camera_stream.add_callback(self.on_frame_msg,
[obstacle_tracking_stream])
self._flags = flags
self._logger = erdos.utils.setup_logging(self.config.name,
self.config.log_file_name)
self._csv_logger = erdos.utils.setup_csv_logging(
self.config.name + '-csv', self.config.csv_log_file_name)
self._camera_setup = camera_setup
self.model = init_model(self._flags.qd_track_config_path,
checkpoint=self._flags.qd_track_model_path,
device='cuda:0',
cfg_options=None)
self.classes = ('pedestrian', 'rider', 'car', 'bus', 'truck',
'bicycle', 'motorcycle', 'train')
self.frame_id = 0

@staticmethod
def connect(camera_stream):
obstacle_tracking_stream = erdos.WriteStream()
return [obstacle_tracking_stream]

def destroy(self):
self._logger.warn('destroying {}'.format(self.config.name))

@erdos.profile_method()
def on_frame_msg(self, msg, obstacle_tracking_stream):
"""Invoked when a FrameMessage is received on the camera stream."""
from qdtrack.apis import inference_model

self._logger.debug('@{}: {} received frame'.format(
msg.timestamp, self.config.name))
assert msg.frame.encoding == 'BGR', 'Expects BGR frames'
start_time = time.time()
image_np = msg.frame.as_bgr_numpy_array()
results = inference_model(self.model, image_np, self.frame_id)
self.frame_id += 1

bbox_result, track_result = results.values()
obstacles = []
for k, v in track_result.items():
track_id = k
bbox = v['bbox'][None, :]
score = bbox[4]
label_id = v['label']
label = self.classes[label_id]
if label in ['pedestrian', 'rider']:
label = 'person'
if label in OBSTACLE_LABELS:
bounding_box_2D = BoundingBox2D(bbox[0], bbox[2], bbox[1],
bbox[3])
obstacles.append(
Obstacle(bounding_box_2D,
score,
label,
track_id,
bounding_box_2D=bounding_box_2D))
runtime = (time.time() - start_time) * 1000
obstacle_tracking_stream.send(
ObstaclesMessage(msg.timestamp, obstacles, runtime))
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ nuscenes-devkit
progress
pyquaternion
scikit-learn==0.22.2
mmcv>=0.3.0
mmdet
##### CARLA dependencies #####
networkx==2.2