diff --git a/toolkit/amd_data_analysis_toolkit/object_detection/generate-visualization.py b/toolkit/amd_data_analysis_toolkit/object_detection/generate-visualization.py index e62769bfaf..b48df7ad41 100644 --- a/toolkit/amd_data_analysis_toolkit/object_detection/generate-visualization.py +++ b/toolkit/amd_data_analysis_toolkit/object_detection/generate-visualization.py @@ -77,7 +77,7 @@ if not os.path.exists(inputImageDirectory): - print "ERROR Invalid Input Image Directory"; + print("ERROR Invalid Input Image Directory") exit(); if not os.path.exists(outputDirectory): @@ -172,7 +172,7 @@ accuracyMismatch = float(totalMismatch)/totalBoundingBox*100 #Results Summary -print "resultsSummary.txt generation .." +print("resultsSummary.txt generation ..") orig_stdout = sys.stdout sys.stdout = open(resultsDirectory+'/resultsSummary.txt','w') print("\n\n ***************** OBJECT DETECTION SUMMARY ***************** \n"); @@ -197,13 +197,13 @@ print('Match Accuracy -- '+str(np.around(accuracyMatch,decimals=2))+' %'); print('Mismatch Accuracy -- '+str(np.around(accuracyMismatch,decimals=2))+' %'); sys.stdout = orig_stdout -print "resultsSummary.txt generated" +print("resultsSummary.txt generated") #generate label summary labelMatch = [] -for i in xrange(20): +for i in range(20): labelMatch.append([]) - for j in xrange(8): + for j in range(8): labelMatch[i].append(0) for i in range(labelElements): @@ -243,17 +243,17 @@ labelMatch[i][3] = numBoxes # Label Summary -print "labelSummary.csv generation .." +print("labelSummary.csv generation ..") orig_stdout = sys.stdout sys.stdout = open(resultsDirectory+'/labelSummary.csv','w') print("Label ID, Label Description, Images in DataBase, Bounding Boxes in DataBase, Bounding Boxes Matched, Bounding Boxes Mismatched, Bounding Boxes Unknown, Bounding Boxes Not Found "); for i in range(20): print("%s,%s,%d,%d,%d,%d,%d,%d"%(labelMatch[i][0], labelMatch[i][1], labelMatch[i][2], labelMatch[i][3], labelMatch[i][4], labelMatch[i][5], labelMatch[i][6], labelMatch[i][7])); sys.stdout = orig_stdout -print "labelSummary.csv generated" +print("labelSummary.csv generated") # generate html file -print "index.html generation .." +print("index.html generation ..") #orig_stdout = sys.stdout sys.stdout = open(toolKit_dir+'/index.html','w') @@ -722,7 +722,7 @@ """ sys.stdout = orig_stdout print confidence_match_boxes -print "len = ", len(confidence_match_boxes) +print("len = ", len(confidence_match_boxes)) """ freq_match = collections.Counter(confidence_match_boxes) fVal = 0.99 @@ -734,8 +734,8 @@ i = i-1 freq_match = collections.OrderedDict(sorted(freq_match.items())) -keys_match = freq_match.keys() -values_match = freq_match.values() +keys_match = list(freq_match.keys()) +values_match = list(freq_match.values()) freq_mismatch = collections.Counter(confidence_mismatch_boxes) fVal = 0.99 @@ -747,8 +747,8 @@ i = i-1 freq_mismatch = collections.OrderedDict(sorted(freq_mismatch.items())) -keys_mismatch = freq_mismatch.keys() -values_mismatch = freq_mismatch.values() +keys_mismatch = list(freq_mismatch.keys()) +values_mismatch = list(freq_mismatch.values()) #Cummulative Success/Failure print("\tgoogle.charts.load('current', {packages: ['corechart', 'line']});"); @@ -977,20 +977,20 @@ boxText = [] conf = [] -for i in xrange(gtElements): +for i in range(gtElements): gtText.append([]) boxText.append([]) conf.append([]) - for j in xrange(16): + for j in range(16): gtText[i].append("") boxText[i].append("") conf[i].append("") #should hold 15 bounding boxes per image as of now!!!!!!!!!!!!! -for i in xrange(gtElements): +for i in range(gtElements): n = 1 - for j in xrange(1,16): + for j in range(1,16): if n < len(gtLines[i]): gtText[i][0] = gtLines[i][0] gtText[i][j] = gtLines[i][n] @@ -998,49 +998,49 @@ #should hold 15 bounding boxes per image as of now!!!!!!!!!!!!! -for i in xrange(boxElements): +for i in range(boxElements): n = 1 - for j in xrange(1,16): + for j in range(1,16): if n < len(boxLines[i]): boxText[i][0] = boxLines[i][0] boxText[i][j] = boxLines[i][n] n = n+6 -for i in xrange(boxElements): +for i in range(boxElements): n = 6 - for j in xrange(1,16): + for j in range(1,16): if n < len(boxLines[i]): conf[i][0] = boxLines[i][0] conf[i][j] = boxLines[i][n] n = n+6 checked_box = [False] * len(dirs) checked_gt = [False] * len(dirs) -for i in xrange(len(dirs)): +for i in range(len(dirs)): print("\t\t