Skip to content
Closed
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
24 changes: 24 additions & 0 deletions convert_floats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import re

def replace_np_float(directory):
# Compile a regex pattern for 'float' surrounded by word boundaries
pattern = re.compile(r'\bnp.float\b')

for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.py'):
file_path = os.path.join(root, file)
with open(file_path, 'r') as f:
content = f.read()

# Use the regex pattern to replace 'float' with 'float'
modified_content = pattern.sub('float', content)

# Write the modified content back to the file
with open(file_path, 'w') as f:
f.write(modified_content)

# Specify the directory
directory = './'
replace_np_float(directory)
28 changes: 28 additions & 0 deletions macos_installation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
conda create --name btrack_exp python=3.8
conda activate btrack_exp

cd $BASE_STATION_ROOT$
pip3 install -r requirements.txt
pip3 uninstall numpy opencv-python
conda install numpy=1.19.5 opencv=4.6
conda install pybind11 loguru pandas seaborn scipy

cd ~
mkdir 3rd_party
cd 3rd_party

git clone https://github.com/gatagat/lap
cd lap
python3 setup.py build
python3 setup.py install

cd ..
git clone https://github.com/samson-wang/cython_bbox.git
cd cython_bbox
python3 setup.py build
python3 setup.py install

cd..
git clone git@github.com:inspiren-inc/ins_btrack.git -b ins-btrack
cd ins_btrack
python3 setup.py develop
30 changes: 9 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#!/usr/bin/env python
# Copyright (c) Megvii, Inc. and its affiliates. All Rights Reserved

import re
from setuptools import setup, Extension, find_namespace_packages
import setuptools
import glob
from os import path
import torch
from torch.utils.cpp_extension import CppExtension

torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
assert torch_ver >= [1, 3], "Requires PyTorch >= 1.3"

import re
import pybind11 # Import Pybind11

def get_extensions():
this_dir = path.dirname(path.abspath(__file__))
Expand All @@ -20,19 +13,15 @@ def get_extensions():
sources = glob.glob(path.join(extensions_dir, "**", "*.cpp"))

sources = [main_source] + sources
extension = CppExtension

extra_compile_args = {"cxx": ["-O3"]}
define_macros = []

include_dirs = [extensions_dir]
extra_compile_args = ["-O3", "-std=c++11"]
include_dirs = [extensions_dir, pybind11.get_include()] # Add Pybind11 include directory

ext_modules = [
extension(
Extension(
"yolox._C",
sources,
include_dirs=include_dirs,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
)
]
Expand All @@ -47,18 +36,17 @@ def get_extensions():
).group(1)


with open("README.md", "r") as f:
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()


setuptools.setup(
setup(
name="yolox",
version=version,
author="basedet team",
python_requires=">=3.6",
long_description=long_description,
ext_modules=get_extensions(),
classifiers=["Programming Language :: Python :: 3", "Operating System :: OS Independent"],
cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension},
packages=setuptools.find_namespace_packages(),
packages=find_namespace_packages(),
)
2 changes: 1 addition & 1 deletion tutorials/centertrack/byte_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class STrack(BaseTrack):
def __init__(self, tlwh, score):

# wait activate
self._tlwh = np.asarray(tlwh, dtype=np.float)
self._tlwh = np.asarray(tlwh, dtype=float)
self.kalman_filter = None
self.mean, self.covariance = None, None
self.is_activated = False
Expand Down
36 changes: 18 additions & 18 deletions tutorials/centertrack/mot_online/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ def ious(atlbrs, btlbrs):

:rtype ious np.ndarray
"""
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float)
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=float)
if ious.size == 0:
return ious

ious = bbox_ious(
np.ascontiguousarray(atlbrs, dtype=np.float),
np.ascontiguousarray(btlbrs, dtype=np.float)
np.ascontiguousarray(atlbrs, dtype=float),
np.ascontiguousarray(btlbrs, dtype=float)
)

return ious
Expand Down Expand Up @@ -109,13 +109,13 @@ def embedding_distance(tracks, detections, metric='cosine'):
:return: cost_matrix np.ndarray
"""

cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=float)
if cost_matrix.size == 0:
return cost_matrix
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
#for i, track in enumerate(tracks):
#cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
return cost_matrix

Expand All @@ -127,17 +127,17 @@ def embedding_distance2(tracks, detections, metric='cosine'):
:return: cost_matrix np.ndarray
"""

cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=float)
if cost_matrix.size == 0:
return cost_matrix
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
#for i, track in enumerate(tracks):
#cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
track_features = np.asarray([track.features[0] for track in tracks], dtype=np.float)
track_features = np.asarray([track.features[0] for track in tracks], dtype=float)
cost_matrix2 = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
track_features = np.asarray([track.features[len(track.features)-1] for track in tracks], dtype=np.float)
track_features = np.asarray([track.features[len(track.features)-1] for track in tracks], dtype=float)
cost_matrix3 = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
for row in range(len(cost_matrix)):
cost_matrix[row] = (cost_matrix[row]+cost_matrix2[row]+cost_matrix3[row])/3
Expand All @@ -149,11 +149,11 @@ def vis_id_feature_A_distance(tracks, detections, metric='cosine'):
det_features = []
leg1 = len(tracks)
leg2 = len(detections)
cost_matrix = np.zeros((leg1, leg2), dtype=np.float)
cost_matrix_det = np.zeros((leg1, leg2), dtype=np.float)
cost_matrix_track = np.zeros((leg1, leg2), dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
cost_matrix = np.zeros((leg1, leg2), dtype=float)
cost_matrix_det = np.zeros((leg1, leg2), dtype=float)
cost_matrix_track = np.zeros((leg1, leg2), dtype=float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
if leg2 != 0:
cost_matrix_det = np.maximum(0.0, cdist(det_features, det_features, metric))
if leg1 != 0:
Expand All @@ -167,8 +167,8 @@ def vis_id_feature_A_distance(tracks, detections, metric='cosine'):
if leg2 > 10:
leg2 = 10
detections = detections[:10]
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
return track_features, det_features, cost_matrix, cost_matrix_det, cost_matrix_track

def gate_cost_matrix(kf, cost_matrix, tracks, detections, only_position=False):
Expand Down
2 changes: 1 addition & 1 deletion tutorials/cstrack/byte_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class STrack(BaseTrack):
def __init__(self, tlwh, score):

# wait activate
self._tlwh = np.asarray(tlwh, dtype=np.float)
self._tlwh = np.asarray(tlwh, dtype=float)
self.kalman_filter = None
self.mean, self.covariance = None, None
self.is_activated = False
Expand Down
2 changes: 1 addition & 1 deletion tutorials/cstrack/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class STrack(BaseTrack):
def __init__(self, tlwh, score, temp_feat, buffer_size=30):

# wait activate
self._tlwh = np.asarray(tlwh, dtype=np.float)
self._tlwh = np.asarray(tlwh, dtype=float)
self.kalman_filter = None
self.mean, self.covariance = None, None
self.is_activated = False
Expand Down
2 changes: 1 addition & 1 deletion tutorials/ctracker/byte_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class STrack(BaseTrack):
def __init__(self, tlwh, score):

# wait activate
self._tlwh = np.asarray(tlwh, dtype=np.float)
self._tlwh = np.asarray(tlwh, dtype=float)
self.kalman_filter = None
self.mean, self.covariance = None, None
self.is_activated = False
Expand Down
36 changes: 18 additions & 18 deletions tutorials/ctracker/mot_online/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ def ious(atlbrs, btlbrs):

:rtype ious np.ndarray
"""
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float)
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=float)
if ious.size == 0:
return ious

ious = bbox_ious(
np.ascontiguousarray(atlbrs, dtype=np.float),
np.ascontiguousarray(btlbrs, dtype=np.float)
np.ascontiguousarray(atlbrs, dtype=float),
np.ascontiguousarray(btlbrs, dtype=float)
)

return ious
Expand Down Expand Up @@ -109,13 +109,13 @@ def embedding_distance(tracks, detections, metric='cosine'):
:return: cost_matrix np.ndarray
"""

cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=float)
if cost_matrix.size == 0:
return cost_matrix
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
#for i, track in enumerate(tracks):
#cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
return cost_matrix

Expand All @@ -127,17 +127,17 @@ def embedding_distance2(tracks, detections, metric='cosine'):
:return: cost_matrix np.ndarray
"""

cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=float)
if cost_matrix.size == 0:
return cost_matrix
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
#for i, track in enumerate(tracks):
#cost_matrix[i, :] = np.maximum(0.0, cdist(track.smooth_feat.reshape(1,-1), det_features, metric))
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
cost_matrix = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
track_features = np.asarray([track.features[0] for track in tracks], dtype=np.float)
track_features = np.asarray([track.features[0] for track in tracks], dtype=float)
cost_matrix2 = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
track_features = np.asarray([track.features[len(track.features)-1] for track in tracks], dtype=np.float)
track_features = np.asarray([track.features[len(track.features)-1] for track in tracks], dtype=float)
cost_matrix3 = np.maximum(0.0, cdist(track_features, det_features, metric)) # Nomalized features
for row in range(len(cost_matrix)):
cost_matrix[row] = (cost_matrix[row]+cost_matrix2[row]+cost_matrix3[row])/3
Expand All @@ -149,11 +149,11 @@ def vis_id_feature_A_distance(tracks, detections, metric='cosine'):
det_features = []
leg1 = len(tracks)
leg2 = len(detections)
cost_matrix = np.zeros((leg1, leg2), dtype=np.float)
cost_matrix_det = np.zeros((leg1, leg2), dtype=np.float)
cost_matrix_track = np.zeros((leg1, leg2), dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
cost_matrix = np.zeros((leg1, leg2), dtype=float)
cost_matrix_det = np.zeros((leg1, leg2), dtype=float)
cost_matrix_track = np.zeros((leg1, leg2), dtype=float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
if leg2 != 0:
cost_matrix_det = np.maximum(0.0, cdist(det_features, det_features, metric))
if leg1 != 0:
Expand All @@ -167,8 +167,8 @@ def vis_id_feature_A_distance(tracks, detections, metric='cosine'):
if leg2 > 10:
leg2 = 10
detections = detections[:10]
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
det_features = np.asarray([track.curr_feat for track in detections], dtype=float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=float)
return track_features, det_features, cost_matrix, cost_matrix_det, cost_matrix_track

def gate_cost_matrix(kf, cost_matrix, tracks, detections, only_position=False):
Expand Down
2 changes: 1 addition & 1 deletion tutorials/fairmot/byte_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class STrack(BaseTrack):
def __init__(self, tlwh, score):

# wait activate
self._tlwh = np.asarray(tlwh, dtype=np.float)
self._tlwh = np.asarray(tlwh, dtype=float)
self.kalman_filter = None
self.mean, self.covariance = None, None
self.is_activated = False
Expand Down
2 changes: 1 addition & 1 deletion tutorials/fairmot/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class STrack(BaseTrack):
def __init__(self, tlwh, score, temp_feat, buffer_size=30):

# wait activate
self._tlwh = np.asarray(tlwh, dtype=np.float)
self._tlwh = np.asarray(tlwh, dtype=float)
self.kalman_filter = None
self.mean, self.covariance = None, None
self.is_activated = False
Expand Down
Loading