def run(): fileList = os.listdir(cfg.resultsFolder) resultsFileList = filter(lambda element: '.result' in element, fileList) for resultsFile in resultsFileList: resultsFilePath = cfg.resultsFolder + '/' +resultsFile file = open(resultsFilePath, 'r') imageResults = pickle.load(file) boxes = imageResults['bboxes'] scores = imageResults['scores'] imagepath = imageResults['imagepath'] filename = os.path.basename(imagepath) if boxes is None: print 'No pedestrians found for image '+imagepath continue print 'Saving results for image '+filename idx = np.where(scores > cfg.decision_threshold) boxes = boxes[idx] scores = scores[idx] boxes, scores = nms.non_max_suppression_fast(boxes, scores, overlapthresh= cfg.nmsOverlapThresh) img = Image.open(imagepath) #Show the results on a colored image img = drawing.drawResultsOnImage(img, boxes, scores) io.imsave('Results/'+filename, img) file.close() print 'Finished!'
def run(): fileList = os.listdir(cfg.resultsFolder) resultsFileList = filter(lambda element: '.result' in element, fileList) for resultsFile in resultsFileList: resultsFilePath = cfg.resultsFolder + '/' +resultsFile file = open(resultsFilePath, 'rb') imageResults = pickle.load(file) boxes = imageResults['bboxes'] scores = imageResults['scores'] imagepath = imageResults['imagepath'] filename = os.path.basename(imagepath) if boxes is None: print ('No pedestrians found for image '+imagepath) continue print ('Saving results for image '+filename) idx = np.where(scores > cfg.decision_threshold) boxes = boxes[idx] scores = scores[idx] boxes, scores = nms.non_max_suppression_fast(boxes, scores, overlapthresh= cfg.nmsOverlapThresh) img = Image.open(imagepath) #Show the results on a colored image img = drawing.drawResultsOnImage(img, boxes, scores) img.save('Results/'+filename,"PNG") file.close() print ('Finished!')
def run(): imagePath = 'Images/Image001.png' bboxes, scores = detector.testImage(imagePath, applyNMS=True) img = Image.open(imagePath) img = drawing.drawResultsOnImage(img, bboxes, scores) if platform.system() is 'Windows': plt.imshow(img) #img.show() does not work properly on windows. We upse matplotlib.imshow instead plt.show() else: img.show()
def run(): imagePath = 'Images/Image001.png' bboxes, scores = detector.testImage(imagePath, applyNMS=True) img = Image.open(imagePath) img = drawing.drawResultsOnImage(img, bboxes, scores) if platform.system() is 'Windows': plt.imshow( img ) #img.show() does not work properly on windows. We upse matplotlib.imshow instead plt.show() else: img.show()
def run(): if cfg.exp_methodology == 2: #Check which one is the negative class (background) negclass = cfg.data.index(cfg.negative_Class) #Open results file, it contains the 'candidates' structure. file = open(cfg.resultsFolder + '/Ce_ccl.results', 'r') candidates = pickle.load(file) if candidates['bboxes'] is None: print 'No signals found' else: #for each image in cfg.testFolderPath extension = '.jpg' #For each stored bounding box imagepath = '' img = None for index in range(0, len(candidates['bboxes'])): i_image = candidates['bboxes'][index][0] i_box = candidates['bboxes'][index][-4:] i_prediction = candidates['prediction'][index] if int(i_prediction) != int( negclass ): # Do not print boxes predicted as background predicted_sign = cfg.data[int(i_prediction)] real_sign = cfg.data[int(candidates['bboxes'][index][1])] results_curr_img_path = 'Results/' + i_image + extension if os.path.isfile(results_curr_img_path): # If exists #print 'exist!' imagepath = results_curr_img_path else: #print 'NOT exist!' imagepath = cfg.testFolderPath + '/' + i_image + extension img = Image.open(imagepath) if img is not None: print 'Drawing results on ' + i_image + extension img = drawing.drawResultsOnImage( img, i_box, predicted_sign, real_sign) io.imsave(results_curr_img_path, img) file.close()
def run(): start_time = time.time() imagePath = 'Images/im.jpg' bboxes, scores = detector.testImage(imagePath, applyNMS=True) img = Image.open(imagePath) img = drawing.drawResultsOnImage(img, bboxes, scores) print 'Finish process. Ready to plot' print("Finish Process --- %s seconds ---" % (time.time() - start_time)) if platform.system() is 'Windows': plt.imshow( img ) #img.show() does not work properly on windows. We upse matplotlib.imshow instead plt.show() else: img.show()
def run(): if cfg.exp_methodology == 2: #Check which one is the negative class (background) negclass = cfg.data.index(cfg.negative_Class) #Open results file, it contains the 'candidates' structure. file = open(cfg.resultsFolder+'/Ce_ccl.results', 'r') candidates = pickle.load(file) if candidates['bboxes'] is None: print 'No signals found' else: #for each image in cfg.testFolderPath extension = '.jpg' #For each stored bounding box imagepath = ''; img = None; for index in range(0, len(candidates['bboxes'])): i_image = candidates['bboxes'][index][0] i_box = candidates['bboxes'][index][-4:] i_prediction = candidates['prediction'][index] if int(i_prediction) != int(negclass): # Do not print boxes predicted as background predicted_sign = cfg.data[int(i_prediction)] real_sign = cfg.data[int(candidates['bboxes'][index][1])] results_curr_img_path = 'Results/' + i_image + extension if os.path.isfile(results_curr_img_path): # If exists #print 'exist!' imagepath = results_curr_img_path; else: #print 'NOT exist!' imagepath = cfg.testFolderPath + '/' + i_image + extension; img = Image.open(imagepath) if img is not None: print 'Drawing results on ' + i_image + extension img = drawing.drawResultsOnImage(img, i_box, predicted_sign, real_sign) io.imsave(results_curr_img_path, img) file.close()