Know how to call a return function in the command line of tlt:


Please I try to automate the training with TLT, so at the evaluate step I created a function for reading XML file to select the network with a large mAP, and then I try to know how to call this function in the command line of tlt:
os.system ("tlt ssd evaluate --gpu_index = 0 -e /workspace/tlt-experiments/Data/Work/resnet18/config/TrainEvaluator.txt -m / workspace / tlt-experiments / Data / Work / resnet18 / ResultTrain / weights / network-name -k KEY ")

I tried to replace network-name by the return of my function but it displays an error

FileNotFoundError: [Errno 2] No such file or directory: '/ workspace / tlt-experiments / Data / Work / resnet18 / ResultTrain / weights // fileEvaluate'

any suggestions please
thank you

Can you double check your command? Seems that there are unnecessary spaces.

fileEvaluate it’s a return of a function, I don’t know if we can insert it in the line of tlt?

      fileEvaluate = self.FindHighestmAP(file,WeightFolder)

FileNotFoundError: [Errno 2] No such file or directory: ‘/workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/fileEvaluate’

fileEvaluate : ssd_resnet18_epoch_074.tlt

Firstly, please check if /workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/ssd_resnet18_epoch_074.tlt works.

yes /workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/ssd_resnet18_epoch_074.tlt works

You can try to export. For example,
os.system("export fileEvaluate='ssd_resnet18_epoch_074.tlt'; ls /workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/$fileEvaluate ")

no it does not work

ls: cannot access ‘/workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/ssd_resnet18_epoch_074.tlt’: No such file or directory

But you mention above that /workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/ssd_resnet18_epoch_074.tlt works , right?

yes by specifying


the command works, but when I replace the latter with the return of the fileEvaluate function it does not recognize,

os.system("tlt ssd evaluate --gpu_index=0 -e /workspace/tlt-experiments/Data/Work/resnet18/config/TrainEvaluator.txt -m /workspace/tlt-experiments/Data/Work/resnet18/ResultTrain/weights/ssd_resnet18_epoch_074.tlt -k KEY ")

def FindHighestmAP(sel,file, WeightFolder):
      # Lire les deux colonnes mAP et epoch
      # parcourir les lignes de la colonnes mAP et trouvé la grande valeur
      # chercher la correspondance de cette valeur dans la colonne epoch
      # retourner le nom du reseau avec le num de l'epoch
         with open (file, "r") as csvfile:
               reader = csv.reader(csvfile)
               ListmAP = []
               ListEpoch = []
               for row in reader:
               #collected = ",".join(collected)
               # delete the first element(str)
               #find the max value in list
               print("Largest element is:", max(ListmAP))
               #find the index of max value
               index = ListmAP.index(max(ListmAP))+2
               for fi in os.listdir(WeightFolder):
                     # si l'index de num est = ListmAP.index(max(ListmAP))+2
                     #return  this model
                     fil = os.path.splitext(fi)[0]
                     if fil.endswith(str(index)):
                        return fi

Please refer to below code.
This example will run “mask_rcnn evaluate” against one tlt file.

import os
import glob

def FindHighestmAP ():
    for i in glob.glob("result_coco/model.step-720.tlt"):
        return i

tlt_file = FindHighestmAP()

os.system("tlt mask_rcnn evaluate -e /workspace/demo_3.0/maskrcnn/specs/resnet50.txt -k nvidia_tlt -m  /workspace/demo_3.0/maskrcnn/%s " % (tlt_file) )

Thanks, for the solution