-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from kadirnar/tracker
The code architecture has been updated.
- Loading branch information
Showing
28 changed files
with
633 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from torchyolo.predict import YoloHub | ||
|
||
__version__ = "0.2.3" | ||
__version__ = "0.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,24 @@ | ||
from typing import Optional | ||
from torchyolo.utils.config_utils import get_config | ||
|
||
MODEL_TYPE_TO_MODEL_CLASS_NAME = { | ||
"yolov5": "Yolov5DetectionModel", | ||
"yolov6": "Yolov6DetectionModel", | ||
"yolov7": "Yolov7DetectionModel", | ||
"yolov8": "Yolov8DetectionModel", | ||
"yolox": "YoloxDetectionModel", | ||
} | ||
|
||
|
||
class AutoDetectionModel: | ||
def from_pretrained( | ||
model_type: str, | ||
model_path: Optional[str] = None, | ||
config_path: Optional[str] = None, | ||
device: Optional[str] = None, | ||
confidence_threshold: float = 0.3, | ||
iou_threshold: float = 0.5, | ||
image_size: int = None, | ||
**kwargs, | ||
config_path: str, | ||
): | ||
""" | ||
Loads a DetectionModel from given path. | ||
Args: | ||
model_type: str | ||
Name of the detection framework (example: "yolov5", "mmdet", "detectron2") | ||
model_path: str | ||
Path of the detection model (ex. 'model.pt') | ||
config_path: str | ||
Path of the config file (ex. 'mmdet/configs/cascade_rcnn_r50_fpn_1x.py') | ||
device: str | ||
Device, "cpu" or "cuda:0" | ||
mask_threshold: float | ||
Value to threshold mask pixels, should be between 0 and 1 | ||
confidence_threshold: float | ||
All predictions with score < confidence_threshold will be discarded | ||
category_mapping: dict: str to str | ||
Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"} | ||
category_remapping: dict: str to int | ||
Remap category ids based on category names, after performing inference e.g. {"car": 3} | ||
load_at_init: bool | ||
If True, automatically loads the model at initalization | ||
image_size: int | ||
Inference input size. | ||
Returns: | ||
Returns an instance of a DetectionModel | ||
Raises: | ||
ImportError: If given {model_type} framework is not installed | ||
""" | ||
|
||
config = get_config(config_path) | ||
model_type = config.DETECTOR_CONFIG.DETECTOR_TYPE | ||
model_class_name = MODEL_TYPE_TO_MODEL_CLASS_NAME[model_type] | ||
DetectionModel = getattr( | ||
__import__(f"torchyolo.modelhub.{model_type}", fromlist=[model_class_name]), model_class_name | ||
) | ||
|
||
return DetectionModel( | ||
model_path=model_path, | ||
config_path=config_path, | ||
device=device, | ||
confidence_threshold=confidence_threshold, | ||
iou_threshold=iou_threshold, | ||
image_size=image_size, | ||
**kwargs, | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
BYTE_TRACK: | ||
# The name of the sort | ||
TRACK_BUFFER: 25 | ||
# The buffer for the track | ||
FRAME_RATE: 30 | ||
# The frame rate of the video | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
NORFAIR_TRACK: | ||
DISTANCE_FUNCTION: "frobenius" # mean_manhattan, mean_euclidean, iou, iou_opt | ||
DISTANCE_THRESHOLD: 500 | ||
HIT_COUNTER_MAX: 15 | ||
INITIALIZATION_DELAY: null | ||
POINTWISE_HIT_COUNTER_MAX: 4 | ||
DETECTION_THRESHOLD: 0 | ||
PAST_DETECTIONS_LENGTH: 4 | ||
REID_DISTANCE_THRESHOLD: 0 | ||
REID_HIT_COUNTER_MAX: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
OC_SORT: | ||
# The name of the sort | ||
CONF_THRESHOLD: 0.05 | ||
# The threshold for the confidence score | ||
IOU_THRESHOLD: 0.3 | ||
# The threshold for the IOU score | ||
MAX_AGE: 30 | ||
# The maximum age of the track | ||
MIN_HITS: 3 | ||
# The minimum number of hits for the track | ||
DELTA_T: 3 | ||
# The time interval between two frames | ||
ASSO_FUNC: "iou" # giou, ciou, diou, ct_dist | ||
# The association function | ||
INERTIA: 0.2 | ||
# The inertia of the track | ||
USE_BYTE: False | ||
# Whether to use byte as the unit of the bounding box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SORT_TRACK: | ||
# The name of the sort | ||
MAX_AGE: 1 | ||
# The maximum number of frames to keep alive a track without associated detections | ||
MIN_HITS: 3 | ||
# The minimum number of associated detections before track initialization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
STRONG_SORT: | ||
ECC: True # activate camera motion compensation | ||
MC_LAMBDA: 0.995 # matching with both appearance (1 - MC_LAMBDA) and motion cost | ||
EMA_ALPHA: 0.9 # updates appearance state in an exponential moving average manner | ||
MAX_DIST: 0.2 # The matching threshold. Samples with larger distance are considered an invalid match | ||
MAX_IOU_DISTANCE: 0.7 # Gating threshold. Associations with cost larger than this value are disregarded. | ||
MAX_AGE: 30 # Maximum number of missed misses before a track is deleted | ||
N_INIT: 3 # Number of frames that a track remains in initialization phase | ||
NN_BUDGET: 100 # Maximum size of the appearance descriptors gallery |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.