changeset 1221:5a207c838323

correcting recursive errors
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 19 Jun 2023 22:37:45 -0400
parents 2dc9899b73ae
children 69b531c7a061
files scripts/dltrack.py scripts/nomad/site-parameters-optimization.py
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/dltrack.py	Mon Jun 19 20:11:12 2023 -0400
+++ b/scripts/dltrack.py	Mon Jun 19 22:37:45 2023 -0400
@@ -13,7 +13,7 @@
 args = parser.parse_args()
 
 # Load a model
-model = YOLO('/home/nicolas/Research/Data/classification-models/yolov8x.pt ') # seg yolov8x-seg.pt
+model = YOLO('/home/nicolas/Research/Data/classification-models/yolov8x.pt') # seg yolov8x-seg.pt
 # seg could be used on cropped image... if can be loaded and kept in memory
 # model = YOLO('/home/nicolas/Research/Data/classification-models/yolo_nas_l.pt ') # AttributeError: 'YoloNAS_L' object has no attribute 'get'
 
--- 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)