def main(): folder = "../../../dataset/images" value_file = folder + "/bases.txt" imgs, files = sc.read_imgs(folder) values = sc.read_values(value_file) threshes = sc.saturation_process(imgs) finals = [] totals = [] scores = [] for (img, thresh, file, value) in zip(imgs, threshes, files, values): total, final = sc.find_contour(img, thresh) score = sc.f1_measure(value, total) finals.append(final) totals.append(total) scores.append(score) save = zip(files, imgs, threshes, finals, values, totals, scores) rate = np.sum(scores) / len(scores) for (file, img, thresh, final, value, total, score) in save: print( "Filename: %s, Detected objects: %d, Actual value: %d, Score: %5.3f" % (file, total, value, score)) print( "\n ######## \n ######## \n Average success in this batch: %5.3f \n" % (rate))
def main(): folder = "../../../Opencv_Test/DataSet1" #"../../../dataset/images" value_file = folder + "/bases.txt" imgs, files = sc.read_imgs(folder) values = sc.read_values(value_file) threshes = sc.saturation_process(imgs) finals = [] totals = [] scores = [] recalls = [] precisions = [] for (img, thresh, file, value) in zip(imgs, threshes, files, values): total, final = sc.blob_detection(img, thresh) score, recall, precision = sc.f1_measure(value, total) finals.append(final) totals.append(total) scores.append(score) recalls.append(recall) precisions.append(precision) save = zip(files, imgs, threshes, finals, values, totals, scores, recalls, precisions) rate = np.sum(scores) / len (scores) rate_r = np.sum(recalls) / len (recalls) rate_p = np.sum(precisions) / len (precisions) for (file, img, thresh, final, value, total, score, recall, precision) in save: print("Filename: %s, Detected objects: %d, Actual value: %d, Score: %5.3f" % (file, total, value, score)) print("\n ######## \n ######## \n Average success in this batch: %5.3f \n Average recall: %5.3f \n Average precision: %5.3f" % (rate, rate_r, rate_p))