Mercurial Hosting > traffic-intelligence
diff scripts/nomad/site-parameters-optimization.py @ 1221:5a207c838323
correcting recursive errors
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 19 Jun 2023 22:37:45 -0400 |
parents | 8a626226793e |
children | 051cf5bddc1f |
line wrap: on
line diff
--- a/scripts/nomad/site-parameters-optimization.py Mon Jun 19 20:11:12 2023 -0400 +++ b/scripts/nomad/site-parameters-optimization.py Mon Jun 19 22:37:45 2023 -0400 @@ -7,7 +7,7 @@ import numpy as np -def loadParametersStartProcess(filename, intersections): +def loadParameters(filename): # load initial parameters from x.txt f = open(filename, 'r+') l = f.readline() @@ -15,11 +15,8 @@ f.close() # create para-value list - para = paraValueList(x) + return paraValueList(x) - # run process including trackingfeature, groupfeature, load groundtruth, compute mota - print(process(para, intersections)) - def paraValueList(x): #create para-value list #list of the 8 parameters and their values @@ -43,7 +40,7 @@ return para -def process(para, intersections): +def process(para, intersections, recursive): Mota = [] gtDatabaseaAbsPaths = [] configFileAbsPaths = [] @@ -54,9 +51,9 @@ intersectionAbsPath = os.path.abspath(intersectionPath) os.chdir(intersectionAbsPath) # iterate through all the subdirectories to find ground truth sqlite files - newPaths = [os.path.abspath(intersectionAbsPath + '/' + file) for file in glob.glob('**/*_gt.sqlite', recursive=True)] + newPaths = [os.path.abspath(fn) for fn in glob.glob(intersectionAbsPath+'/*_gt.sqlite', recursive=recursive)] gtDatabaseaAbsPaths.extend(newPaths) - configFilename = os.path.abspath(intersectionAbsPath + '/' + glob.glob('*.cfg', recursive=True)[0]) + configFilename = os.path.abspath(glob.glob(intersectionAbsPath+'/*.cfg', recursive=recursive)[0]) configFileAbsPaths.extend([configFilename]*len(newPaths)) os.chdir(cwd) for gtDatabaseAbsPath, configFileAbsPath in zip(gtDatabaseaAbsPaths, configFileAbsPaths): @@ -116,7 +113,10 @@ # intersections = eval(intersections) # Just write the intersections to optimize here - intersections = ['../12-laurier'] + intersections = ['.']#['/home/nicolas/Research/Data/montreal/12-07-laurier'] + recursive = False - loadParametersStartProcess(sys.argv[1], intersections) + para = loadParameters(sys.argv[1]) + # run process including trackingfeature, groupfeature, load groundtruth, compute mota + print(process(para, intersections, recursive)) sys.exit(0)