-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathenvironment.py
executable file
·66 lines (54 loc) · 2.42 KB
/
environment.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import importlib
import os
class EnvSettings:
def __init__(self):
pytracking_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
self.results_path = '{}/tracking_results/'.format(pytracking_path)
self.segmentation_path = '{}/segmentation_results/'.format(pytracking_path)
self.network_path = '{}/networks/'.format(pytracking_path)
self.result_plot_path = '{}/result_plots/'.format(pytracking_path)
self.otb_path = ''
self.nfs_path = ''
self.uav_path = ''
self.tpl_path = ''
self.vot_path = ''
self.got10k_path = ''
self.lasot_path = ''
self.trackingnet_path = ''
self.davis_dir = ''
self.youtubevos_dir = ''
self.got_packed_results_path = ''
self.got_reports_path = ''
self.tn_packed_results_path = ''
def create_default_local_file():
comment = {'results_path': 'Where to store tracking results',
'network_path': 'Where tracking networks are stored.'}
path = os.path.join(os.path.dirname(__file__), 'local.py')
with open(path, 'w') as f:
settings = EnvSettings()
f.write('from pytracking.evaluation.environment import EnvSettings\n\n')
f.write('def local_env_settings():\n')
f.write(' settings = EnvSettings()\n\n')
f.write(' # Set your local paths here.\n\n')
for attr in dir(settings):
comment_str = None
if attr in comment:
comment_str = comment[attr]
attr_val = getattr(settings, attr)
if not attr.startswith('__') and not callable(attr_val):
if comment_str is None:
f.write(' settings.{} = \'{}\'\n'.format(attr, attr_val))
else:
f.write(' settings.{} = \'{}\' # {}\n'.format(attr, attr_val, comment_str))
f.write('\n return settings\n\n')
def env_settings():
env_module_name = 'pytracking.evaluation.local'
try:
env_module = importlib.import_module(env_module_name)
return env_module.local_env_settings()
except:
env_file = os.path.join(os.path.dirname(__file__), 'local.py')
# Create a default file
create_default_local_file()
raise RuntimeError('YOU HAVE NOT SETUP YOUR local.py!!!\n Go to "{}" and set all the paths you need. '
'Then try to run again.'.format(env_file))