Skip to content

Instantly share code, notes, and snippets.

View benjaminlq's full-sized avatar

Le Quan benjaminlq

  • Singapore Management University
  • Singapore
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
""" Step 4: Init new stracks"""
for inew in u_detection:
track = detections[inew]
if track.score < 0.7:
continue
else:
track.activate(self.kalman_filter, self.frame_id) # Initiate a new track
class ByteTrackArgument:
track_thresh = 0.5 # High_threshold
track_buffer = 50 # Number of frame lost tracklets are kept
match_thresh = 0.8 # Matching threshold for first stage linear assignment
aspect_ratio_thresh = 10.0 # Minimum bounding box aspect ratio
min_box_area = 1.0 # Minimum bounding box area
mot20 = False # If used, bounding boxes are not clipped.
MIN_THRESHOLD = 0.001
trackers = [BYTETracker(ByteTrackArgument), BYTETracker(ByteTrackArgument), BYTETracker(ByteTrackArgument)]
frame_id = 0
results = []
history = deque()
while True:
if frame_id % 20 == 0:
print(f'Processing frame {frame_id}.')
ret_val, online_im = cap.read()
if ret_val:
tracker = BYTETracker(args)
for image in images:
dets = detector(image)
online_targets = tracker.update(dets, info_imgs, img_size)
### Load and Train YOLOv8 Model ###
# Load a model
model = YOLO("yolov8m.pt") # load a pretrained model (recommended for training)
# Train the model
results = model.train(data=f"{HOME}/datasets/basketball.yaml", imgsz=TEST_SIZE, batch=BATCH_SIZE, epochs=EPOCHS, plots=True)
!git clone https://github.com/ifzhang/ByteTrack.git
%cd ByteTrack
!pip3 install -r requirements.txt
!python3 setup.py develop
!pip3 install cython
!pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
!pip3 install cython_bbox
!yolo task=detect mode=predict model=./runs/detect/train/weights/best.pt conf=0.4 source=./datasets/aerial_view_ships.mp4 save=True
from ultralytics import YOLO
model = YOLO("./runs/detect/train/weights/best.pt")
results = model.predict(source="./datasets/val/")
!yolo task=detect mode=predict model=./runs/detect/train/weights/best.pt conf=0.4 source=./datasets/val/ save=True