Mercurial > hg > nsaunier > traffic-intelligence
annotate scripts/nomad/site-parameters-optimization.py @ 1223:051cf5bddc1f
work on optimization (improved for feature tracking)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 21 Jun 2023 23:57:54 -0400 |
| parents | 5a207c838323 |
| children | a09a80cdc118 |
| rev | line source |
|---|---|
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 #! /usr/bin/env python3 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 import os |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 import sys |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 import glob |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 from trafficintelligence import storage, moving |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 import subprocess |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 import numpy as np |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 |
|
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
10 def loadParameters(filename): |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 # load initial parameters from x.txt |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
12 f = open(filename, 'r+') |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 l = f.readline() |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 x = [s for s in l.strip().split(" ")] |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 f.close() |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
16 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
17 # create para-value list |
|
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
18 return paraValueList(x) |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
19 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
20 def paraValueList(x): |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
21 #create para-value list |
|
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
22 #list of the parameters and their values |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
23 p = ['--feature-quality', #]0.-0.4] |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
24 '--min-feature-distanceklt', #]0.-10] |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
25 '--block-size', #[1-10]integer |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
26 '--window-size', #[1-10]integer |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
27 '--min-feature-displacement', #[0.0001-0.1] 0.05 |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
28 '--acceleration-bound', #[1.-5.] 3 |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
29 '--deviation-bound', #[-1, 1] 0.6 |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
30 #p[3] = '--min-tracking-error' #[0.01-0.3] |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
31 '--min-feature-time', #[2-100]integer |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
32 '--mm-connection-distance', #[0.5-100] |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
33 '--mm-segmentation-distance', #[1-100] ~mm-connection-distance / 2.5 |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
34 '--min-nfeatures-group'] #[2-4] |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
35 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
36 para = [] |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
37 if len(x) == 4: |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
38 for n in range(4): |
|
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
39 para = para + [p[-4+n],x[n]] |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
40 else: |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
41 for n in range(len(x)): |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
42 para = para + [p[n],x[n]] |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
43 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
44 return para |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
45 |
|
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
46 def process(para, intersections, recursive): |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
47 Mota = [] |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
48 gtDatabaseaAbsPaths = [] |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
49 configFileAbsPaths = [] |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
50 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
51 cwd = os.getcwd() |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
52 # move to the location of the intersection |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
53 for intersectionPath in intersections: |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
54 intersectionAbsPath = os.path.abspath(intersectionPath) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
55 os.chdir(intersectionAbsPath) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
56 # iterate through all the subdirectories to find ground truth sqlite files |
|
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
57 newPaths = [os.path.abspath(fn) for fn in glob.glob(intersectionAbsPath+'/*_gt.sqlite', recursive=recursive)] |
|
1190
d24d57e4de24
work on optimization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1189
diff
changeset
|
58 gtDatabaseaAbsPaths.extend(newPaths) |
|
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
59 configFilename = os.path.abspath(glob.glob(intersectionAbsPath+'/*.cfg', recursive=recursive)[0]) |
|
1190
d24d57e4de24
work on optimization
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1189
diff
changeset
|
60 configFileAbsPaths.extend([configFilename]*len(newPaths)) |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
61 os.chdir(cwd) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
62 for gtDatabaseAbsPath, configFileAbsPath in zip(gtDatabaseaAbsPaths, configFileAbsPaths): |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
63 gtDatabaseBasename = gtDatabaseAbsPath[:-10] |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
64 videoFilename = gtDatabaseBasename + ".avi" # careful, it may be necessary to check video type / extension |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
65 if not os.path.exists(videoFilename): |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
66 print('Video file {} does not exist'.format(videoFilename)) |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
67 databaseFilename = gtDatabaseBasename + ".sqlite" |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
68 gtDatabaseDirname = os.path.dirname(gtDatabaseAbsPath) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
69 homographyFilename = gtDatabaseDirname + "/homography.txt" |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
70 maskFilename = gtDatabaseDirname + "/mask.png" |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
71 # Skip feature tracking if the user specified to optimize only grouping parameters |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
72 if len(para) > 8: |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
73 # Track features |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
74 trackingFeature(para, configFileAbsPath, videoFilename, databaseFilename, homographyFilename, maskFilename) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
75 # Group features |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
76 groupFeature(para, configFileAbsPath, videoFilename, databaseFilename, homographyFilename, maskFilename) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
77 #load trajectory |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
78 objects = storage.loadTrajectoriesFromSqlite(databaseFilename, 'object') |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
79 #load ground truth |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
80 annotations = storage.loadTrajectoriesFromSqlite(gtDatabaseAbsPath, 'object') |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
81 # Appending negative mota because nomad minimizes the output |
|
1191
f3b3696f5640
adding time interval for MOTA computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1190
diff
changeset
|
82 matchingDistance = 5 |
|
1192
606817bc31e8
bug correction
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1191
diff
changeset
|
83 inter = moving.TimeInterval.unionIntervals([a.getTimeInterval() for a in annotations]) |
|
1191
f3b3696f5640
adding time interval for MOTA computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1190
diff
changeset
|
84 motp, mota, mt, mme, fpt, gt, gtMatches, toMatches = moving.computeClearMOT(annotations, objects, matchingDistance, inter.first, inter.last) |
|
f3b3696f5640
adding time interval for MOTA computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1190
diff
changeset
|
85 Mota.append(-mota) |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
86 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
87 # Change to the previous directory |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
88 os.chdir(cwd) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
89 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
90 return np.mean(Mota) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
91 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
92 def trackingFeature(para, config, video, db, homo, mask): |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
93 # remove previous tracking |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
94 if os.path.exists(db): |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
95 os.remove(db) |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
96 # trackingfeature command parameters |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
97 tf = ['feature-based-tracking', config, '--tf', '--video-filename', video, '--database-filename', db, '--homography-filename', homo, '--mask-filename', mask] |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
98 # run in command line and print directly |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
99 subprocess.check_output(tf + para) |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
100 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
101 def groupFeature(para, config, video, db, homo, mask): |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
102 #remove previous grouping |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
103 storage.deleteFromSqlite(db, 'object') |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
104 #groupfeature command parameters |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
105 gf = ['feature-based-tracking', config, '--gf', '--video-filename', video, '--database-filename', db, '--homography-filename', homo, '--mask-filename', mask] |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
106 #run in command line and print directly |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
107 subprocess.check_output(gf + para) # ['--min-feature-time', 'x', '--mm-connection-distance', 'x', '--mm-segmentation-distance', 'x', '--min-nfeatures-group', 'x'] |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
108 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
109 |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
110 if __name__ == "__main__": |
|
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
111 # Load args that were given with select-arguments.py |
|
1219
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
112 # with open('arguments.txt', 'r') as f: |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
113 # args = f.read().split('\n') |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
114 # intersections = args[0] |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
115 # optimizeGroupingOnly = eval(args[1]) |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
116 # intersections = eval(intersections) |
|
8a626226793e
update where optimization uses either nomad-parameter file depending on optimizing 1 or 2 steps
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1192
diff
changeset
|
117 |
|
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
118 # Just write the intersections to optimize here: do not use '~' for home directory |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
119 intersections = ['/home/nicolas/Research/Data3/test-optimization/12-laurier'] |
|
1221
5a207c838323
correcting recursive errors
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1219
diff
changeset
|
120 recursive = False |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
121 |
|
1223
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
122 # first and only argument should be the |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
123 if len(sys.argv) == 2: |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
124 para = loadParameters(sys.argv[1]) |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
125 # run process including trackingfeature, groupfeature, load groundtruth, compute mota |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
126 print(process(para, intersections, recursive)) |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
127 else: |
|
051cf5bddc1f
work on optimization (improved for feature tracking)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1221
diff
changeset
|
128 print('Usage: site-parameters-optimization.py [initial-parameters text file]') |
|
1186
7117a31555c1
Etienne Beauchamp s work on optimization with Nomad software
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
129 sys.exit(0) |
