File size: 1,144 Bytes
d9ebe88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Custom ByteTrack configuration optimized for Indian traffic conditions.

Tuning rationale (vs Ultralytics defaults):
- Lower thresholds: Indian roads have heavy occlusion (autos behind buses)
- Higher track_buffer: Vehicles disappear behind large vehicles for longer
- Looser match_thresh: Apparent shape changes during partial occlusion

Reference: https://docs.ultralytics.com/modes/track/
"""
import os
import tempfile

_YAML_CONTENT = """# UrbanFlow — ByteTrack config for Indian heterogeneous traffic
# Base: https://github.com/ultralytics/ultralytics/blob/main/ultralytics/cfg/trackers/bytetrack.yaml

tracker_type: bytetrack
track_high_thresh: 0.20
track_low_thresh: 0.08
new_track_thresh: 0.20
track_buffer: 45
match_thresh: 0.75
fuse_score: true
"""

_CONFIG_PATH = os.path.join(tempfile.gettempdir(), "urbanflow_bytetrack.yaml")


def get_tracker_path():
    """Write custom YAML once and return its path."""
    if not os.path.exists(_CONFIG_PATH):
        with open(_CONFIG_PATH, "w") as f:
            f.write(_YAML_CONTENT)
        print(f"[tracker] Custom ByteTrack config written: {_CONFIG_PATH}")
    return _CONFIG_PATH