diff --git a/Main.py b/Main.py new file mode 100644 index 0000000..9ecba92 --- /dev/null +++ b/Main.py @@ -0,0 +1,63 @@ +import time +from runMe import * +from busProjectTest import runTest +import sys +import os + +class my_time: + + def tic(self): + self.t = time.time() + + def toc(self): + self.elapsed = float(time.time()) - float(self.t) + s = "elapsed time is %0.3f seconds" % self.elapsed + print(s) + return self.elapsed + +i = 0 +saveDir = None +while(i < len(sys.argv)): + arg = sys.argv[i] + print(arg) + if('-myAnns' in arg): + myAnnFileName = sys.argv[i + 1] + myAnnFileName = os.path.join(os.getcwd(), myAnnFileName) + if ('-anns' in arg): + annFileNameGT = sys.argv[i + 1] + annFileNameGT = os.path.join(os.getcwd(), annFileNameGT) + if('-buses' in arg): + busDir = sys.argv[i + 1] + busDir = os.path.join(os.getcwd(), busDir) + if ('-saveDir' in arg): + saveDir = sys.argv[i + 1] + saveDir = os.path.join(os.getcwd(), saveDir) + if(not os.path.exists(saveDir)): + os.mkdir(saveDir) + if('-h' in arg): + print('This script compares the ground truth (GT) and the estimated detections\nUsage: \n-myAnns ') + print('-anns \n-buses ') + print('-saveDir use this option if you want to save the images with the annotations') + print('example:\npython busProjectTest.py -myAnns myannotations.txt -anns anotationsTrain.txt -buses busesDir -saveDir Figures') + print('-h - show this message and exit') + sys.exit() + i += 1 + +if(i == 0): + print('This script compares the ground truth (GT) and the estimated detections\nUsage: \n-myAnns ') + print('-anns \n-buses ') + print('-saveDir use this option if you want to save the images with the annotations') + print('example:\npython busProjectTest.py -myAnns myannotations.txt -anns anotationsTrain.txt -buses busesDir -saveDir Figures') + print('-h - show this message and exit') + sys.exit() + +t = my_time() + +t.tic() + +run(myAnnFileName, busDir) + +elapsed = t.toc() + +runTest(annFileNameGT, myAnnFileName, busDir , saveDir, elapsed) + diff --git a/Original Pictures/DSCF1013.JPG b/Original Pictures/DSCF1013.JPG new file mode 100644 index 0000000..15949bb Binary files /dev/null and b/Original Pictures/DSCF1013.JPG differ diff --git a/Original Pictures/DSCF1015.JPG b/Original Pictures/DSCF1015.JPG new file mode 100644 index 0000000..7506f8f Binary files /dev/null and b/Original Pictures/DSCF1015.JPG differ diff --git a/Original Pictures/DSCF1016.JPG b/Original Pictures/DSCF1016.JPG new file mode 100644 index 0000000..8070b77 Binary files /dev/null and b/Original Pictures/DSCF1016.JPG differ diff --git a/Original Pictures/DSCF1017.JPG b/Original Pictures/DSCF1017.JPG new file mode 100644 index 0000000..1a70b6a Binary files /dev/null and b/Original Pictures/DSCF1017.JPG differ diff --git a/Original Pictures/DSCF1021.JPG b/Original Pictures/DSCF1021.JPG new file mode 100644 index 0000000..60022a1 Binary files /dev/null and b/Original Pictures/DSCF1021.JPG differ diff --git a/Original Pictures/DSCF1023.JPG b/Original Pictures/DSCF1023.JPG new file mode 100644 index 0000000..990512a Binary files /dev/null and b/Original Pictures/DSCF1023.JPG differ diff --git a/Original Pictures/DSCF1025.JPG b/Original Pictures/DSCF1025.JPG new file mode 100644 index 0000000..22713ef Binary files /dev/null and b/Original Pictures/DSCF1025.JPG differ diff --git a/Original Pictures/DSCF1029.JPG b/Original Pictures/DSCF1029.JPG new file mode 100644 index 0000000..e54af20 Binary files /dev/null and b/Original Pictures/DSCF1029.JPG differ diff --git a/Original Pictures/DSCF1032.JPG b/Original Pictures/DSCF1032.JPG new file mode 100644 index 0000000..51e61f8 Binary files /dev/null and b/Original Pictures/DSCF1032.JPG differ diff --git a/Original Pictures/DSCF1037.JPG b/Original Pictures/DSCF1037.JPG new file mode 100644 index 0000000..f460630 Binary files /dev/null and b/Original Pictures/DSCF1037.JPG differ diff --git a/Original Pictures/DSCF1038.JPG b/Original Pictures/DSCF1038.JPG new file mode 100644 index 0000000..4c73ac7 Binary files /dev/null and b/Original Pictures/DSCF1038.JPG differ diff --git a/Original Pictures/DSCF1040.JPG b/Original Pictures/DSCF1040.JPG new file mode 100644 index 0000000..cf557e5 Binary files /dev/null and b/Original Pictures/DSCF1040.JPG differ diff --git a/Original Pictures/DSCF1042.JPG b/Original Pictures/DSCF1042.JPG new file mode 100644 index 0000000..413bbaa Binary files /dev/null and b/Original Pictures/DSCF1042.JPG differ diff --git a/Original Pictures/DSCF1044.JPG b/Original Pictures/DSCF1044.JPG new file mode 100644 index 0000000..8cf8153 Binary files /dev/null and b/Original Pictures/DSCF1044.JPG differ diff --git a/Original Pictures/DSCF1048.JPG b/Original Pictures/DSCF1048.JPG new file mode 100644 index 0000000..cd3db1e Binary files /dev/null and b/Original Pictures/DSCF1048.JPG differ diff --git a/Original Pictures/DSCF1049.JPG b/Original Pictures/DSCF1049.JPG new file mode 100644 index 0000000..034cf43 Binary files /dev/null and b/Original Pictures/DSCF1049.JPG differ diff --git a/Original Pictures/DSCF1050.JPG b/Original Pictures/DSCF1050.JPG new file mode 100644 index 0000000..47b7b9e Binary files /dev/null and b/Original Pictures/DSCF1050.JPG differ diff --git a/Original Pictures/DSCF1053.JPG b/Original Pictures/DSCF1053.JPG new file mode 100644 index 0000000..834bec5 Binary files /dev/null and b/Original Pictures/DSCF1053.JPG differ diff --git a/Original Pictures/DSCF1056.JPG b/Original Pictures/DSCF1056.JPG new file mode 100644 index 0000000..139b036 Binary files /dev/null and b/Original Pictures/DSCF1056.JPG differ diff --git a/Original Pictures/DSCF1059.JPG b/Original Pictures/DSCF1059.JPG new file mode 100644 index 0000000..ba7c631 Binary files /dev/null and b/Original Pictures/DSCF1059.JPG differ diff --git a/Original Pictures/DSCF1061.JPG b/Original Pictures/DSCF1061.JPG new file mode 100644 index 0000000..ea3ef02 Binary files /dev/null and b/Original Pictures/DSCF1061.JPG differ diff --git a/Original Pictures/DSCF1064.JPG b/Original Pictures/DSCF1064.JPG new file mode 100644 index 0000000..971f7cc Binary files /dev/null and b/Original Pictures/DSCF1064.JPG differ diff --git a/Original Pictures/DSCF1065.JPG b/Original Pictures/DSCF1065.JPG new file mode 100644 index 0000000..83ad467 Binary files /dev/null and b/Original Pictures/DSCF1065.JPG differ diff --git a/Original Pictures/DSCF1066.JPG b/Original Pictures/DSCF1066.JPG new file mode 100644 index 0000000..9a0617d Binary files /dev/null and b/Original Pictures/DSCF1066.JPG differ diff --git a/Original Pictures/DSCF1068.JPG b/Original Pictures/DSCF1068.JPG new file mode 100644 index 0000000..d66ea7c Binary files /dev/null and b/Original Pictures/DSCF1068.JPG differ diff --git a/Original Pictures/DSCF1070.JPG b/Original Pictures/DSCF1070.JPG new file mode 100644 index 0000000..8667b88 Binary files /dev/null and b/Original Pictures/DSCF1070.JPG differ diff --git a/Original Pictures/DSCF1072.JPG b/Original Pictures/DSCF1072.JPG new file mode 100644 index 0000000..d8fe3e1 Binary files /dev/null and b/Original Pictures/DSCF1072.JPG differ diff --git a/Original Pictures/DSCF1074.JPG b/Original Pictures/DSCF1074.JPG new file mode 100644 index 0000000..c2d98e3 Binary files /dev/null and b/Original Pictures/DSCF1074.JPG differ diff --git a/Original Pictures/DSCF1077.JPG b/Original Pictures/DSCF1077.JPG new file mode 100644 index 0000000..7c28ee2 Binary files /dev/null and b/Original Pictures/DSCF1077.JPG differ diff --git a/Original Pictures/DSCF1081.JPG b/Original Pictures/DSCF1081.JPG new file mode 100644 index 0000000..f0d44f1 Binary files /dev/null and b/Original Pictures/DSCF1081.JPG differ diff --git a/Original Pictures/DSCF1082.JPG b/Original Pictures/DSCF1082.JPG new file mode 100644 index 0000000..979cdf6 Binary files /dev/null and b/Original Pictures/DSCF1082.JPG differ diff --git a/Original Pictures/DSCF1086.JPG b/Original Pictures/DSCF1086.JPG new file mode 100644 index 0000000..f2adc9d Binary files /dev/null and b/Original Pictures/DSCF1086.JPG differ diff --git a/Original Pictures/DSCF1088.JPG b/Original Pictures/DSCF1088.JPG new file mode 100644 index 0000000..95277e9 Binary files /dev/null and b/Original Pictures/DSCF1088.JPG differ diff --git a/Original Pictures/DSCF1090.JPG b/Original Pictures/DSCF1090.JPG new file mode 100644 index 0000000..eb5dd85 Binary files /dev/null and b/Original Pictures/DSCF1090.JPG differ diff --git a/Original Pictures/DSCF1092.JPG b/Original Pictures/DSCF1092.JPG new file mode 100644 index 0000000..111ef52 Binary files /dev/null and b/Original Pictures/DSCF1092.JPG differ diff --git a/Original Pictures/DSCF1094.JPG b/Original Pictures/DSCF1094.JPG new file mode 100644 index 0000000..6dfda85 Binary files /dev/null and b/Original Pictures/DSCF1094.JPG differ diff --git a/Original Pictures/DSCF1097.JPG b/Original Pictures/DSCF1097.JPG new file mode 100644 index 0000000..c95008a Binary files /dev/null and b/Original Pictures/DSCF1097.JPG differ diff --git a/Original Pictures/DSCF1099.JPG b/Original Pictures/DSCF1099.JPG new file mode 100644 index 0000000..c706cde Binary files /dev/null and b/Original Pictures/DSCF1099.JPG differ diff --git a/Original Pictures/DSCF1101.JPG b/Original Pictures/DSCF1101.JPG new file mode 100644 index 0000000..5860c93 Binary files /dev/null and b/Original Pictures/DSCF1101.JPG differ diff --git a/Original Pictures/DSCF1103.JPG b/Original Pictures/DSCF1103.JPG new file mode 100644 index 0000000..b7964b2 Binary files /dev/null and b/Original Pictures/DSCF1103.JPG differ diff --git a/Original Pictures/DSCF1104.JPG b/Original Pictures/DSCF1104.JPG new file mode 100644 index 0000000..ecf7e90 Binary files /dev/null and b/Original Pictures/DSCF1104.JPG differ diff --git a/Original Pictures/DSCF1105.JPG b/Original Pictures/DSCF1105.JPG new file mode 100644 index 0000000..2648218 Binary files /dev/null and b/Original Pictures/DSCF1105.JPG differ diff --git a/Original Pictures/DSCF1106.JPG b/Original Pictures/DSCF1106.JPG new file mode 100644 index 0000000..bfde090 Binary files /dev/null and b/Original Pictures/DSCF1106.JPG differ diff --git a/Original Pictures/DSCF1109.JPG b/Original Pictures/DSCF1109.JPG new file mode 100644 index 0000000..d818121 Binary files /dev/null and b/Original Pictures/DSCF1109.JPG differ diff --git a/Original Pictures/DSCF1110.JPG b/Original Pictures/DSCF1110.JPG new file mode 100644 index 0000000..590d1fe Binary files /dev/null and b/Original Pictures/DSCF1110.JPG differ diff --git a/Original Pictures/DSCF1111.JPG b/Original Pictures/DSCF1111.JPG new file mode 100644 index 0000000..4c86e8a Binary files /dev/null and b/Original Pictures/DSCF1111.JPG differ diff --git a/Original Pictures/DSCF1114.JPG b/Original Pictures/DSCF1114.JPG new file mode 100644 index 0000000..94c6d85 Binary files /dev/null and b/Original Pictures/DSCF1114.JPG differ diff --git a/Original Pictures/DSCF1116.JPG b/Original Pictures/DSCF1116.JPG new file mode 100644 index 0000000..84ed271 Binary files /dev/null and b/Original Pictures/DSCF1116.JPG differ diff --git a/Original Pictures/DSCF1120.JPG b/Original Pictures/DSCF1120.JPG new file mode 100644 index 0000000..8ce0252 Binary files /dev/null and b/Original Pictures/DSCF1120.JPG differ diff --git a/Original Pictures/DSCF1122.JPG b/Original Pictures/DSCF1122.JPG new file mode 100644 index 0000000..b1d6d77 Binary files /dev/null and b/Original Pictures/DSCF1122.JPG differ diff --git a/Original Pictures/DSCF1125.JPG b/Original Pictures/DSCF1125.JPG new file mode 100644 index 0000000..3c1b907 Binary files /dev/null and b/Original Pictures/DSCF1125.JPG differ diff --git a/Original Pictures/DSCF1129.JPG b/Original Pictures/DSCF1129.JPG new file mode 100644 index 0000000..51c4329 Binary files /dev/null and b/Original Pictures/DSCF1129.JPG differ diff --git a/Original Pictures/DSCF1130.JPG b/Original Pictures/DSCF1130.JPG new file mode 100644 index 0000000..2cafd00 Binary files /dev/null and b/Original Pictures/DSCF1130.JPG differ diff --git a/Original Pictures/DSCF1132.JPG b/Original Pictures/DSCF1132.JPG new file mode 100644 index 0000000..e694119 Binary files /dev/null and b/Original Pictures/DSCF1132.JPG differ diff --git a/Original Pictures/DSCF1133.JPG b/Original Pictures/DSCF1133.JPG new file mode 100644 index 0000000..afd3238 Binary files /dev/null and b/Original Pictures/DSCF1133.JPG differ diff --git a/Original Pictures/DSCF1135.JPG b/Original Pictures/DSCF1135.JPG new file mode 100644 index 0000000..0896671 Binary files /dev/null and b/Original Pictures/DSCF1135.JPG differ diff --git a/Original Pictures/DSCF1137.JPG b/Original Pictures/DSCF1137.JPG new file mode 100644 index 0000000..570b7a9 Binary files /dev/null and b/Original Pictures/DSCF1137.JPG differ diff --git a/Original Pictures/DSCF1140.JPG b/Original Pictures/DSCF1140.JPG new file mode 100644 index 0000000..971dfb9 Binary files /dev/null and b/Original Pictures/DSCF1140.JPG differ diff --git a/Original Pictures/DSCF1141.JPG b/Original Pictures/DSCF1141.JPG new file mode 100644 index 0000000..feb28c4 Binary files /dev/null and b/Original Pictures/DSCF1141.JPG differ diff --git a/Original Pictures/DSCF1142.JPG b/Original Pictures/DSCF1142.JPG new file mode 100644 index 0000000..cb155fc Binary files /dev/null and b/Original Pictures/DSCF1142.JPG differ diff --git a/Original Pictures/originalAnnotationsTrain.txt b/Original Pictures/originalAnnotationsTrain.txt new file mode 100644 index 0000000..f1b959d --- /dev/null +++ b/Original Pictures/originalAnnotationsTrain.txt @@ -0,0 +1,60 @@ +DSCF1013.JPG:[1217,1690,489,201,1],[1774,1619,475,224,2],[2313,1566,460,228,3],[1284,1832,497,231,4],[1879,1798,486,228,5],[2429,1742,475,228,6] +DSCF1015.JPG:[641,1342,1181,892,3],[2053,1022,1122,735,6] +DSCF1016.JPG:[1067,1843,1114,613,4],[1954,1278,1021,561,6],[2392,717,964,635,3] +DSCF1017.JPG:[1834,698,789,422,4] +DSCF1021.JPG:[1991,755,923,546,5] +DSCF1023.JPG:[1909,1166,785,452,2] +DSCF1025.JPG:[985,1570,1252,710,6] +DSCF1029.JPG:[129,1648,1271,733,6],[1456,1076,1122,834,2],[2552,826,1058,804,1] +DSCF1032.JPG:[144,1200,983,467,5],[2339,1125,916,456,6] +DSCF1037.JPG:[1210,1712,1469,643,1] +DSCF1038.JPG:[1210,1764,1754,796,2] +DSCF1040.JPG:[462,1813,976,546,2],[1445,1791,871,482,1],[2305,1779,785,463,4] +DSCF1042.JPG:[2021,1682,1013,504,5] +DSCF1044.JPG:[1460,1200,946,523,6] +DSCF1048.JPG:[443,1230,665,314,4],[1498,1181,665,295,5],[2511,1099,703,310,3] +DSCF1049.JPG:[480,998,789,388,4],[1718,1192,740,396,5],[2758,1364,706,347,3] +DSCF1050.JPG:[454,766,804,366,5],[1767,807,792,366,3] +DSCF1053.JPG:[925,1536,1006,516,1],[2010,1510,1013,523,6] +DSCF1056.JPG:[469,957,1234,632,2],[1700,953,1219,662,6] +DSCF1059.JPG:[1221,994,1103,706,2] +DSCF1061.JPG:[488,1648,1361,792,6],[1191,1203,1144,632,2] +DSCF1064.JPG:[2399,358,811,519,3],[585,740,927,579,2] +DSCF1065.JPG:[705,1031,811,306,5],[2193,908,766,306,1] +DSCF1066.JPG:[1019,1121,718,332,1],[2025,1121,695,321,5] +DSCF1068.JPG:[750,343,1316,501,5],[2459,1533,957,527,1] +DSCF1070.JPG:[1617,1413,1028,583,2],[1528,990,878,523,6] +DSCF1072.JPG:[746,1211,916,549,3],[1905,1465,968,534,2] +DSCF1074.JPG:[1127,1319,1742,964,2] +DSCF1077.JPG:[308,1282,1110,620,6],[1700,1342,1133,624,1] +DSCF1081.JPG:[1475,1282,714,396,4] +DSCF1082.JPG:[996,579,957,534,5],[2118,601,946,542,4] +DSCF1086.JPG:[716,975,609,332,4],[1471,971,602,336,2],[2175,1005,594,344,1],[2878,990,602,359,3] +DSCF1088.JPG:[1232,440,789,422,5],[1326,1525,654,370,2] +DSCF1090.JPG:[1920,784,673,370,1] +DSCF1092.JPG:[424,1293,867,538,4],[1636,1521,890,516,5],[2481,1028,751,504,3] +DSCF1094.JPG:[1378,1035,991,583,4] +DSCF1097.JPG:[1326,642,1155,635,5] +DSCF1099.JPG:[1112,556,1114,564,6] +DSCF1101.JPG:[1015,1072,916,504,2] +DSCF1103.JPG:[1475,541,691,359,6],[1168,1880,849,516,5] +DSCF1104.JPG:[1715,493,684,329,5],[1632,1783,774,426,1] +DSCF1105.JPG:[1090,1016,1312,755,2] +DSCF1106.JPG:[1202,1076,1155,624,2] +DSCF1109.JPG:[1053,878,1178,650,3] +DSCF1110.JPG:[686,743,1159,654,3],[1920,792,1174,643,1] +DSCF1111.JPG:[1890,867,1024,576,6],[671,874,1043,583,2] +DSCF1114.JPG:[1535,1177,994,508,6] +DSCF1116.JPG:[1539,1458,998,523,5] +DSCF1120.JPG:[1236,1274,1324,706,3] +DSCF1122.JPG:[1479,949,1009,542,5] +DSCF1125.JPG:[978,930,654,415,1],[1198,1394,815,482,6],[2406,1252,792,460,2] +DSCF1129.JPG:[1408,1772,792,501,6] +DSCF1130.JPG:[1516,1708,755,471,1] +DSCF1132.JPG:[2751,1005,489,250,1],[2283,1278,893,523,4],[174,1663,1406,740,5] +DSCF1133.JPG:[1352,1192,1140,841,1] +DSCF1135.JPG:[1801,1233,605,359,6] +DSCF1137.JPG:[1879,1136,849,478,2] +DSCF1140.JPG:[1722,594,789,284,6] +DSCF1141.JPG:[1793,665,781,276,2] +DSCF1142.JPG:[914,1200,886,388,2],[2010,1211,878,388,1] diff --git a/busProjectModifiedTest.py b/busProjectModifiedTest.py new file mode 100644 index 0000000..1bcd87b --- /dev/null +++ b/busProjectModifiedTest.py @@ -0,0 +1,194 @@ +import os +import sys +import matplotlib +import matplotlib.pyplot as plt +import matplotlib.patches as patches +import numpy as np +import ast + +import imageio + + +#fontdict = {'fontsize':15, 'weight':'bold'} +#plt.switch_backend('Qt5Agg') + +class IMAGE: + + def __init__(self): + self.ROIS = [] + + def set_image(self, im): + self.I = imageio.imread(im) + self.imShape = self.I.shape + + def clear_ROIS(self): + self.ROIS = [] + + def add_ROI(self, pos): + self.ROIS.append(pos) + + def show_ROI(self, title, edgecolor, numGT, text, saveDir = None): + fig, ax = plt.subplots(1) + ax.imshow(self.I) + if(not isinstance(edgecolor,list) and len(self.ROIS) > 0): + edgecolor = [edgecolor] * len(self.ROIS) + for i in range(0,numGT): + ROI = self.ROIS[i] + rect = patches.Rectangle((ROI[0], ROI[1]), ROI[2], ROI[3], linewidth = 1, edgecolor = edgecolor[i], facecolor='none') + ax.add_patch(rect) + for i in range(numGT,len(self.ROIS)): + ROI = self.ROIS[i] + rect = patches.Rectangle((ROI[0], ROI[1]), ROI[2], ROI[3], linewidth = 1, edgecolor = edgecolor[i], facecolor='none', linestyle = '--') + ax.add_patch(rect) + if(saveDir is None): + ax.text(15,160,text, fontdict = fontdict, bbox={'facecolor':'yellow', 'edgecolor':'yellow','alpha':0.5, 'pad':2}) + else: + ax.text(15, 300, text, fontdict=fontdict,bbox={'facecolor': 'yellow', 'edgecolor': 'yellow', 'alpha': 0.5, 'pad': 2}) + plt.title(title) + if(not saveDir is None): + plt.savefig(os.path.join(saveDir, title), dpi = 500) + plt.close() + + def close(self): + plt.close() + +def IOU(boxAList, boxBList): + Th = 0.69 + iou = [] + matches = {} + tp = 0 + fp = len(boxBList) + missed = len(boxAList) + for i in range(len(boxAList)): + boxA = boxAList[i][:4] + iou_ = [] + for j in range(len(boxBList)): + boxB = boxBList[j][:4] + if(not ((boxB[0] <= boxA[0] <= boxB[0] + boxB[2]) or (boxA[0] <= boxB[0] <= boxA[0] + boxA[2]))): + iou_.append(0.0) + continue + xA = max(boxA[0], boxB[0]) + yA = max(boxA[1], boxB[1]) + xB = min(boxA[0] + boxA[2], boxB[0] + boxB[2]) + yB = min(boxA[1] + boxA[3], boxB[1] + boxB[3]) + interArea = (xB - xA + 1) * (yB - yA + 1) + boxAArea = (boxA[2] + 1)*(boxA[3] + 1) + boxBArea = (boxB[2] + 1)*(boxB[3] + 1) + iou_.append(interArea / float(boxAArea + boxBArea - interArea)) + maxIou = max(iou_) + maxIouIndex = iou_.index(max(iou_)) + iou.append(maxIou) + if (maxIouIndex in matches and maxIou > iou[matches[maxIouIndex]]): + if (iou[matches[maxIouIndex]] > Th and boxAList[matches[maxIouIndex]][4] == boxBList[maxIouIndex][4]): + pass + elif(maxIou > Th and boxAList[i][4] == boxBList[maxIouIndex][4]): + tp += 1 + missed -= 1 + fp -= 1 + matches[maxIouIndex] = i + if(not maxIouIndex in matches): + matches[maxIouIndex] = i + if(maxIou > Th and boxAList[i][4] == boxBList[maxIouIndex][4]): + tp += 1 + missed -= 1 + fp -= 1 + return tp, fp, missed, iou + +def runTest(annFileNameGT, myAnnFileName, busDir , saveDir = None, elapsed = None, toPlt = False): + + image = IMAGE() + objectsColors = {'g':'1', 'y':'2', 'w':'3', 's':'4', 'b':'5', 'r':'6'} + objectsColorsInv = {v: k for k, v in objectsColors.items()} + objectsColorsForShow = {'g':'g', 'y':'y', 'w':'w', 's':'tab:gray', 'b':'b', 'r':'r'} + + writtenAnnsLines = {} + annFileEstimations = open(myAnnFileName, 'r') + annFileGT = open(annFileNameGT, 'r') + writtenAnnsLines['Ground_Truth'] = (annFileGT.readlines()) + writtenAnnsLines['Estimation'] = (annFileEstimations.readlines()) + + TP = 0 + FP = 0 + MISS = 0 + + for i in range(len(writtenAnnsLines['Ground_Truth'])): + + lineGT = writtenAnnsLines['Ground_Truth'][i].replace(' ','') + colors = [] + imName = lineGT.split(':')[0] + lineE = [x for x in writtenAnnsLines['Estimation'] if imName == x.split(':')[0]] + if(len(lineE) == 0): + lineE = imName + ':' + else: + lineE = lineE[0] + bus = os.path.join(busDir, imName) + image.set_image(bus) + image.clear_ROIS() + annsGT = lineGT[lineGT.index(':') + 1:].replace('\n', '') + annsE = lineE[lineE.index(':') + 1:].replace('\n', '') + annsGT = ast.literal_eval(annsGT) + if (not isinstance(annsGT, tuple)): + annsGT = [annsGT] + for ann in annsGT: + image.add_ROI(ann[:4]) + colorTag = objectsColorsInv[str(ann[4])] + colors.append(objectsColorsForShow[colorTag]) + numGT = len(annsGT) + if('[' in lineE): + annsE = ast.literal_eval(annsE) + if (not isinstance(annsE, tuple)): + annsE = [annsE] + for ann in annsE: + image.add_ROI(ann[:4]) + colorTag = objectsColorsInv[str(ann[4])] + colors.append(objectsColorsForShow[colorTag]) + tp, fp, missed, iou = IOU(annsGT, annsE) + else: + tp = 0 + fp = 0 + numGT = 0 + missed = len(annsGT) + iou = [] + TP += tp + FP += fp + MISS += missed + print('Image : {}, TP: {} FP: {} MISSED : {}'.format(imName, tp, fp, missed)) + iouStr = ','.join(['{0:.2f}'.format(x) for x in iou]) + text = 'IOU Scores : ' + iouStr + '\nTP = {}, FP = {}, Missed = {} '.format(tp, fp, missed) + if toPlt: + image.show_ROI(edgecolor = colors, title = imName, numGT = numGT , text = text, saveDir = saveDir) + + if(TP == 0): + F1Score = 0 + else: + precision = TP/(TP + FP) + recall = TP/(TP + MISS) + F1Score = 2*(precision * recall)/(precision + recall) + strToWrite = 'Total detections = {}/{}\nTotal False Positives = {}\nTotal missed = {}'.format(TP, TP+MISS, FP, MISS) + strToWrite += '\nF1 SCORE : {0:.3f}'.format(F1Score) + if(not elapsed is None): + strToWrite += '\nTime elapsed : {0:.2f} seconds'.format(elapsed) + print(strToWrite) + if toPlt: + fig, ax = plt.subplots(1) + plt.title('Results', fontdict = {'fontsize':20}) + im = np.zeros((10,26,3), dtype=np.uint8) + im[:,:,2] = 221 + im[:,:,1] = 114 + im[:,:,0] = 102 + ax.imshow(im) + ax.text(4,7, strToWrite, style='italic', fontdict = {'fontsize':50, 'weight':'bold'}) + mng = plt.get_current_fig_manager() + mng.window.showMaximized() + plt.show() + plt.close() + FIG, ax = plt.subplots(1) + plt.title('Results', fontdict = {'fontsize':20}) + ax.imshow(im) + ax.text(2,8, strToWrite, style='italic', fontdict = {'fontsize':20, 'weight':'bold'}) + if(saveDir is None): + saveDir = os.path.join(os.getcwd(), 'Output') + if(not os.path.exists(saveDir)): + os.mkdir(saveDir) + plt.savefig(os.path.join(saveDir,'Results.png'), dpi = 600) + return F1Score, precision, recall, TP, FP, MISS \ No newline at end of file diff --git a/busProjectTest.py b/busProjectTest.py new file mode 100644 index 0000000..4c1ae78 --- /dev/null +++ b/busProjectTest.py @@ -0,0 +1,190 @@ +import os +import sys +import matplotlib +import matplotlib.pyplot as plt +import matplotlib.patches as patches +import numpy as np +import ast + +import imageio + + +fontdict = {'fontsize':15, 'weight':'bold'} +plt.switch_backend('Qt5Agg') + +class IMAGE: + + def __init__(self): + self.ROIS = [] + + def set_image(self, im): + self.I = imageio.imread(im) + self.imShape = self.I.shape + + def clear_ROIS(self): + self.ROIS = [] + + def add_ROI(self, pos): + self.ROIS.append(pos) + + def show_ROI(self, title, edgecolor, numGT, text, saveDir = None): + fig, ax = plt.subplots(1) + ax.imshow(self.I) + if(not isinstance(edgecolor,list) and len(self.ROIS) > 0): + edgecolor = [edgecolor] * len(self.ROIS) + for i in range(0,numGT): + ROI = self.ROIS[i] + rect = patches.Rectangle((ROI[0], ROI[1]), ROI[2], ROI[3], linewidth = 1, edgecolor = edgecolor[i], facecolor='none') + ax.add_patch(rect) + for i in range(numGT,len(self.ROIS)): + ROI = self.ROIS[i] + rect = patches.Rectangle((ROI[0], ROI[1]), ROI[2], ROI[3], linewidth = 1, edgecolor = edgecolor[i], facecolor='none', linestyle = '--') + ax.add_patch(rect) + if(saveDir is None): + ax.text(15,160,text, fontdict = fontdict, bbox={'facecolor':'yellow', 'edgecolor':'yellow','alpha':0.5, 'pad':2}) + else: + ax.text(15, 300, text, fontdict=fontdict,bbox={'facecolor': 'yellow', 'edgecolor': 'yellow', 'alpha': 0.5, 'pad': 2}) + plt.title(title) + if(not saveDir is None): + plt.savefig(os.path.join(saveDir, title), dpi = 500) + plt.close() + + def close(self): + plt.close() + +def IOU(boxAList, boxBList): + Th = 0.69 + iou = [] + matches = {} + tp = 0 + fp = len(boxBList) + missed = len(boxAList) + for i in range(len(boxAList)): + boxA = boxAList[i][:4] + iou_ = [] + for j in range(len(boxBList)): + boxB = boxBList[j][:4] + if(not ((boxB[0] <= boxA[0] <= boxB[0] + boxB[2]) or (boxA[0] <= boxB[0] <= boxA[0] + boxA[2]))): + iou_.append(0.0) + continue + xA = max(boxA[0], boxB[0]) + yA = max(boxA[1], boxB[1]) + xB = min(boxA[0] + boxA[2], boxB[0] + boxB[2]) + yB = min(boxA[1] + boxA[3], boxB[1] + boxB[3]) + interArea = (xB - xA + 1) * (yB - yA + 1) + boxAArea = (boxA[2] + 1)*(boxA[3] + 1) + boxBArea = (boxB[2] + 1)*(boxB[3] + 1) + iou_.append(interArea / float(boxAArea + boxBArea - interArea)) + maxIou = max(iou_) + maxIouIndex = iou_.index(max(iou_)) + iou.append(maxIou) + if (maxIouIndex in matches and maxIou > iou[matches[maxIouIndex]]): + if (iou[matches[maxIouIndex]] > Th and boxAList[matches[maxIouIndex]][4] == boxBList[maxIouIndex][4]): + pass + elif(maxIou > Th and boxAList[i][4] == boxBList[maxIouIndex][4]): + tp += 1 + missed -= 1 + fp -= 1 + matches[maxIouIndex] = i + if(not maxIouIndex in matches): + matches[maxIouIndex] = i + if(maxIou > Th and boxAList[i][4] == boxBList[maxIouIndex][4]): + tp += 1 + missed -= 1 + fp -= 1 + return tp, fp, missed, iou + +def runTest(annFileNameGT, myAnnFileName, busDir , saveDir = None, elapsed = None): + + image = IMAGE() + objectsColors = {'g':'1', 'y':'2', 'w':'3', 's':'4', 'b':'5', 'r':'6'} + objectsColorsInv = {v: k for k, v in objectsColors.items()} + objectsColorsForShow = {'g':'g', 'y':'y', 'w':'w', 's':'tab:gray', 'b':'b', 'r':'r'} + + writtenAnnsLines = {} + annFileEstimations = open(myAnnFileName, 'r') + annFileGT = open(annFileNameGT, 'r') + writtenAnnsLines['Ground_Truth'] = (annFileGT.readlines()) + writtenAnnsLines['Estimation'] = (annFileEstimations.readlines()) + + TP = 0 + FP = 0 + MISS = 0 + + for i in range(len(writtenAnnsLines['Ground_Truth'])): + + lineGT = writtenAnnsLines['Ground_Truth'][i].replace(' ','') + colors = [] + imName = lineGT.split(':')[0] + lineE = [x for x in writtenAnnsLines['Estimation'] if imName == x.split(':')[0]] + if(len(lineE) == 0): + lineE = imName + ':' + else: + lineE = lineE[0] + bus = os.path.join(busDir, imName) + image.set_image(bus) + image.clear_ROIS() + annsGT = lineGT[lineGT.index(':') + 1:].replace('\n', '') + annsE = lineE[lineE.index(':') + 1:].replace('\n', '') + annsGT = ast.literal_eval(annsGT) + if (not isinstance(annsGT, tuple)): + annsGT = [annsGT] + for ann in annsGT: + image.add_ROI(ann[:4]) + colorTag = objectsColorsInv[str(ann[4])] + colors.append(objectsColorsForShow[colorTag]) + numGT = len(annsGT) + if('[' in lineE): + annsE = ast.literal_eval(annsE) + if (not isinstance(annsE, tuple)): + annsE = [annsE] + for ann in annsE: + image.add_ROI(ann[:4]) + colorTag = objectsColorsInv[str(ann[4])] + colors.append(objectsColorsForShow[colorTag]) + tp, fp, missed, iou = IOU(annsGT, annsE) + else: + tp = 0 + fp = 0 + numGT = 0 + missed = len(annsGT) + iou = [] + TP += tp + FP += fp + MISS += missed + print('Image : {}, TP: {} FP: {} MISSED : {}'.format(imName, tp, fp, missed)) + iouStr = ','.join(['{0:.2f}'.format(x) for x in iou]) + text = 'IOU Scores : ' + iouStr + '\nTP = {}, FP = {}, Missed = {} '.format(tp, fp, missed) + image.show_ROI(edgecolor = colors, title = imName, numGT = numGT , text = text, saveDir = saveDir) + + if(TP == 0): + F1Score = 0 + else: + precision = TP/(TP + FP) + recall = TP/(TP + MISS) + F1Score = 2*(precision * recall)/(precision + recall) + strToWrite = 'Total detections = {}/{}\nTotal False Positives = {}\nTotal missed = {}'.format(TP, TP+MISS, FP, MISS) + strToWrite += '\nF1 SCORE : {0:.3f}'.format(F1Score) + if(not elapsed is None): + strToWrite += '\nTime elapsed : {0:.2f} seconds'.format(elapsed) + fig, ax = plt.subplots(1) + plt.title('Results', fontdict = {'fontsize':20}) + im = np.zeros((10,26,3), dtype=np.uint8) + im[:,:,2] = 221 + im[:,:,1] = 114 + im[:,:,0] = 102 + ax.imshow(im) + ax.text(4,7, strToWrite, style='italic', fontdict = {'fontsize':50, 'weight':'bold'}) + mng = plt.get_current_fig_manager() + mng.window.showMaximized() + plt.show() + plt.close() + FIG, ax = plt.subplots(1) + plt.title('Results', fontdict = {'fontsize':20}) + ax.imshow(im) + ax.text(2,8, strToWrite, style='italic', fontdict = {'fontsize':20, 'weight':'bold'}) + if(saveDir is None): + saveDir = os.path.join(os.getcwd(), 'Output') + if(not os.path.exists(saveDir)): + os.mkdir(saveDir) + plt.savefig(os.path.join(saveDir,'Results.png'), dpi = 600) diff --git a/consts.py b/consts.py new file mode 100644 index 0000000..2c1d172 --- /dev/null +++ b/consts.py @@ -0,0 +1,7 @@ +SPLIT_RATE = 0.66 + +NETS = {} + +NETS['faster_rcnn_R_50_FPN_3x'] = { 'config_file' :"COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml", + 'local_coco_weights' :'model_final_280758.pkl', + 'download_coco_weights':'detectron2://COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl'} \ No newline at end of file diff --git a/data/originalData/Main.py b/data/originalData/Main.py new file mode 100644 index 0000000..9ecba92 --- /dev/null +++ b/data/originalData/Main.py @@ -0,0 +1,63 @@ +import time +from runMe import * +from busProjectTest import runTest +import sys +import os + +class my_time: + + def tic(self): + self.t = time.time() + + def toc(self): + self.elapsed = float(time.time()) - float(self.t) + s = "elapsed time is %0.3f seconds" % self.elapsed + print(s) + return self.elapsed + +i = 0 +saveDir = None +while(i < len(sys.argv)): + arg = sys.argv[i] + print(arg) + if('-myAnns' in arg): + myAnnFileName = sys.argv[i + 1] + myAnnFileName = os.path.join(os.getcwd(), myAnnFileName) + if ('-anns' in arg): + annFileNameGT = sys.argv[i + 1] + annFileNameGT = os.path.join(os.getcwd(), annFileNameGT) + if('-buses' in arg): + busDir = sys.argv[i + 1] + busDir = os.path.join(os.getcwd(), busDir) + if ('-saveDir' in arg): + saveDir = sys.argv[i + 1] + saveDir = os.path.join(os.getcwd(), saveDir) + if(not os.path.exists(saveDir)): + os.mkdir(saveDir) + if('-h' in arg): + print('This script compares the ground truth (GT) and the estimated detections\nUsage: \n-myAnns ') + print('-anns \n-buses ') + print('-saveDir use this option if you want to save the images with the annotations') + print('example:\npython busProjectTest.py -myAnns myannotations.txt -anns anotationsTrain.txt -buses busesDir -saveDir Figures') + print('-h - show this message and exit') + sys.exit() + i += 1 + +if(i == 0): + print('This script compares the ground truth (GT) and the estimated detections\nUsage: \n-myAnns ') + print('-anns \n-buses ') + print('-saveDir use this option if you want to save the images with the annotations') + print('example:\npython busProjectTest.py -myAnns myannotations.txt -anns anotationsTrain.txt -buses busesDir -saveDir Figures') + print('-h - show this message and exit') + sys.exit() + +t = my_time() + +t.tic() + +run(myAnnFileName, busDir) + +elapsed = t.toc() + +runTest(annFileNameGT, myAnnFileName, busDir , saveDir, elapsed) + diff --git a/data/originalData/annotations/bus_train.json b/data/originalData/annotations/bus_train.json new file mode 100644 index 0000000..305d22c --- /dev/null +++ b/data/originalData/annotations/bus_train.json @@ -0,0 +1,2228 @@ +{ + "info": { + "description": "busTrain", + "url": "none", + "version": "1.0", + "year": 2019, + "contributor": "Yuval and Lior", + "date_created": "2019/12/12" + }, + "licenses": [ + { + "url": "none", + "id": 1, + "name": "none" + } + ], + "images": [ + { + "license": 1, + "file_name": "DSCF1013.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 1, + "annotations": [ + { + "segmentation": [], + "area": 98289.0, + "iscrowd": 0, + "image_id": 1, + "bbox": [ + 1217.0, + 1690.0, + 489.0, + 201.0 + ], + "category_id": 1, + "id": 0 + }, + { + "segmentation": [], + "area": 106400.0, + "iscrowd": 0, + "image_id": 1, + "bbox": [ + 1774.0, + 1619.0, + 475.0, + 224.0 + ], + "category_id": 2, + "id": 1 + }, + { + "segmentation": [], + "area": 104880.0, + "iscrowd": 0, + "image_id": 1, + "bbox": [ + 2313.0, + 1566.0, + 460.0, + 228.0 + ], + "category_id": 3, + "id": 2 + }, + { + "segmentation": [], + "area": 114807.0, + "iscrowd": 0, + "image_id": 1, + "bbox": [ + 1284.0, + 1832.0, + 497.0, + 231.0 + ], + "category_id": 4, + "id": 3 + }, + { + "segmentation": [], + "area": 110808.0, + "iscrowd": 0, + "image_id": 1, + "bbox": [ + 1879.0, + 1798.0, + 486.0, + 228.0 + ], + "category_id": 5, + "id": 4 + }, + { + "segmentation": [], + "area": 108300.0, + "iscrowd": 0, + "image_id": 1, + "bbox": [ + 2429.0, + 1742.0, + 475.0, + 228.0 + ], + "category_id": 6, + "id": 5 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1015.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 2, + "annotations": [ + { + "segmentation": [], + "area": 1053452.0, + "iscrowd": 0, + "image_id": 2, + "bbox": [ + 641.0, + 1342.0, + 1181.0, + 892.0 + ], + "category_id": 3, + "id": 0 + }, + { + "segmentation": [], + "area": 824670.0, + "iscrowd": 0, + "image_id": 2, + "bbox": [ + 2053.0, + 1022.0, + 1122.0, + 735.0 + ], + "category_id": 6, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1016.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 3, + "annotations": [ + { + "segmentation": [], + "area": 682882.0, + "iscrowd": 0, + "image_id": 3, + "bbox": [ + 1067.0, + 1843.0, + 1114.0, + 613.0 + ], + "category_id": 4, + "id": 0 + }, + { + "segmentation": [], + "area": 572781.0, + "iscrowd": 0, + "image_id": 3, + "bbox": [ + 1954.0, + 1278.0, + 1021.0, + 561.0 + ], + "category_id": 6, + "id": 1 + }, + { + "segmentation": [], + "area": 612140.0, + "iscrowd": 0, + "image_id": 3, + "bbox": [ + 2392.0, + 717.0, + 964.0, + 635.0 + ], + "category_id": 3, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1017.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 4, + "annotations": [ + { + "segmentation": [], + "area": 332958.0, + "iscrowd": 0, + "image_id": 4, + "bbox": [ + 1834.0, + 698.0, + 789.0, + 422.0 + ], + "category_id": 4, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1021.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 5, + "annotations": [ + { + "segmentation": [], + "area": 503958.0, + "iscrowd": 0, + "image_id": 5, + "bbox": [ + 1991.0, + 755.0, + 923.0, + 546.0 + ], + "category_id": 5, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1023.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 6, + "annotations": [ + { + "segmentation": [], + "area": 354820.0, + "iscrowd": 0, + "image_id": 6, + "bbox": [ + 1909.0, + 1166.0, + 785.0, + 452.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1025.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 7, + "annotations": [ + { + "segmentation": [], + "area": 888920.0, + "iscrowd": 0, + "image_id": 7, + "bbox": [ + 985.0, + 1570.0, + 1252.0, + 710.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1029.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 8, + "annotations": [ + { + "segmentation": [], + "area": 931643.0, + "iscrowd": 0, + "image_id": 8, + "bbox": [ + 129.0, + 1648.0, + 1271.0, + 733.0 + ], + "category_id": 6, + "id": 0 + }, + { + "segmentation": [], + "area": 935748.0, + "iscrowd": 0, + "image_id": 8, + "bbox": [ + 1456.0, + 1076.0, + 1122.0, + 834.0 + ], + "category_id": 2, + "id": 1 + }, + { + "segmentation": [], + "area": 850632.0, + "iscrowd": 0, + "image_id": 8, + "bbox": [ + 2552.0, + 826.0, + 1058.0, + 804.0 + ], + "category_id": 1, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1032.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 9, + "annotations": [ + { + "segmentation": [], + "area": 459061.0, + "iscrowd": 0, + "image_id": 9, + "bbox": [ + 144.0, + 1200.0, + 983.0, + 467.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 417696.0, + "iscrowd": 0, + "image_id": 9, + "bbox": [ + 2339.0, + 1125.0, + 916.0, + 456.0 + ], + "category_id": 6, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1037.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 10, + "annotations": [ + { + "segmentation": [], + "area": 944567.0, + "iscrowd": 0, + "image_id": 10, + "bbox": [ + 1210.0, + 1712.0, + 1469.0, + 643.0 + ], + "category_id": 1, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1038.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 11, + "annotations": [ + { + "segmentation": [], + "area": 1396184.0, + "iscrowd": 0, + "image_id": 11, + "bbox": [ + 1210.0, + 1764.0, + 1754.0, + 796.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1040.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 12, + "annotations": [ + { + "segmentation": [], + "area": 532896.0, + "iscrowd": 0, + "image_id": 12, + "bbox": [ + 462.0, + 1813.0, + 976.0, + 546.0 + ], + "category_id": 2, + "id": 0 + }, + { + "segmentation": [], + "area": 419822.0, + "iscrowd": 0, + "image_id": 12, + "bbox": [ + 1445.0, + 1791.0, + 871.0, + 482.0 + ], + "category_id": 1, + "id": 1 + }, + { + "segmentation": [], + "area": 363455.0, + "iscrowd": 0, + "image_id": 12, + "bbox": [ + 2305.0, + 1779.0, + 785.0, + 463.0 + ], + "category_id": 4, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1042.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 13, + "annotations": [ + { + "segmentation": [], + "area": 510552.0, + "iscrowd": 0, + "image_id": 13, + "bbox": [ + 2021.0, + 1682.0, + 1013.0, + 504.0 + ], + "category_id": 5, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1044.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 14, + "annotations": [ + { + "segmentation": [], + "area": 494758.0, + "iscrowd": 0, + "image_id": 14, + "bbox": [ + 1460.0, + 1200.0, + 946.0, + 523.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1048.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 15, + "annotations": [ + { + "segmentation": [], + "area": 208810.0, + "iscrowd": 0, + "image_id": 15, + "bbox": [ + 443.0, + 1230.0, + 665.0, + 314.0 + ], + "category_id": 4, + "id": 0 + }, + { + "segmentation": [], + "area": 196175.0, + "iscrowd": 0, + "image_id": 15, + "bbox": [ + 1498.0, + 1181.0, + 665.0, + 295.0 + ], + "category_id": 5, + "id": 1 + }, + { + "segmentation": [], + "area": 217930.0, + "iscrowd": 0, + "image_id": 15, + "bbox": [ + 2511.0, + 1099.0, + 703.0, + 310.0 + ], + "category_id": 3, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1049.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 16, + "annotations": [ + { + "segmentation": [], + "area": 306132.0, + "iscrowd": 0, + "image_id": 16, + "bbox": [ + 480.0, + 998.0, + 789.0, + 388.0 + ], + "category_id": 4, + "id": 0 + }, + { + "segmentation": [], + "area": 293040.0, + "iscrowd": 0, + "image_id": 16, + "bbox": [ + 1718.0, + 1192.0, + 740.0, + 396.0 + ], + "category_id": 5, + "id": 1 + }, + { + "segmentation": [], + "area": 244982.0, + "iscrowd": 0, + "image_id": 16, + "bbox": [ + 2758.0, + 1364.0, + 706.0, + 347.0 + ], + "category_id": 3, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1050.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 17, + "annotations": [ + { + "segmentation": [], + "area": 294264.0, + "iscrowd": 0, + "image_id": 17, + "bbox": [ + 454.0, + 766.0, + 804.0, + 366.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 289872.0, + "iscrowd": 0, + "image_id": 17, + "bbox": [ + 1767.0, + 807.0, + 792.0, + 366.0 + ], + "category_id": 3, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1053.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 18, + "annotations": [ + { + "segmentation": [], + "area": 519096.0, + "iscrowd": 0, + "image_id": 18, + "bbox": [ + 925.0, + 1536.0, + 1006.0, + 516.0 + ], + "category_id": 1, + "id": 0 + }, + { + "segmentation": [], + "area": 529799.0, + "iscrowd": 0, + "image_id": 18, + "bbox": [ + 2010.0, + 1510.0, + 1013.0, + 523.0 + ], + "category_id": 6, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1056.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 19, + "annotations": [ + { + "segmentation": [], + "area": 779888.0, + "iscrowd": 0, + "image_id": 19, + "bbox": [ + 469.0, + 957.0, + 1234.0, + 632.0 + ], + "category_id": 2, + "id": 0 + }, + { + "segmentation": [], + "area": 806978.0, + "iscrowd": 0, + "image_id": 19, + "bbox": [ + 1700.0, + 953.0, + 1219.0, + 662.0 + ], + "category_id": 6, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1059.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 20, + "annotations": [ + { + "segmentation": [], + "area": 778718.0, + "iscrowd": 0, + "image_id": 20, + "bbox": [ + 1221.0, + 994.0, + 1103.0, + 706.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1061.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 21, + "annotations": [ + { + "segmentation": [], + "area": 1077912.0, + "iscrowd": 0, + "image_id": 21, + "bbox": [ + 488.0, + 1648.0, + 1361.0, + 792.0 + ], + "category_id": 6, + "id": 0 + }, + { + "segmentation": [], + "area": 723008.0, + "iscrowd": 0, + "image_id": 21, + "bbox": [ + 1191.0, + 1203.0, + 1144.0, + 632.0 + ], + "category_id": 2, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1064.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 22, + "annotations": [ + { + "segmentation": [], + "area": 420909.0, + "iscrowd": 0, + "image_id": 22, + "bbox": [ + 2399.0, + 358.0, + 811.0, + 519.0 + ], + "category_id": 3, + "id": 0 + }, + { + "segmentation": [], + "area": 536733.0, + "iscrowd": 0, + "image_id": 22, + "bbox": [ + 585.0, + 740.0, + 927.0, + 579.0 + ], + "category_id": 2, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1065.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 23, + "annotations": [ + { + "segmentation": [], + "area": 248166.0, + "iscrowd": 0, + "image_id": 23, + "bbox": [ + 705.0, + 1031.0, + 811.0, + 306.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 234396.0, + "iscrowd": 0, + "image_id": 23, + "bbox": [ + 2193.0, + 908.0, + 766.0, + 306.0 + ], + "category_id": 1, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1066.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 24, + "annotations": [ + { + "segmentation": [], + "area": 238376.0, + "iscrowd": 0, + "image_id": 24, + "bbox": [ + 1019.0, + 1121.0, + 718.0, + 332.0 + ], + "category_id": 1, + "id": 0 + }, + { + "segmentation": [], + "area": 223095.0, + "iscrowd": 0, + "image_id": 24, + "bbox": [ + 2025.0, + 1121.0, + 695.0, + 321.0 + ], + "category_id": 5, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1068.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 25, + "annotations": [ + { + "segmentation": [], + "area": 659316.0, + "iscrowd": 0, + "image_id": 25, + "bbox": [ + 750.0, + 343.0, + 1316.0, + 501.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 504339.0, + "iscrowd": 0, + "image_id": 25, + "bbox": [ + 2459.0, + 1533.0, + 957.0, + 527.0 + ], + "category_id": 1, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1070.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 26, + "annotations": [ + { + "segmentation": [], + "area": 599324.0, + "iscrowd": 0, + "image_id": 26, + "bbox": [ + 1617.0, + 1413.0, + 1028.0, + 583.0 + ], + "category_id": 2, + "id": 0 + }, + { + "segmentation": [], + "area": 459194.0, + "iscrowd": 0, + "image_id": 26, + "bbox": [ + 1528.0, + 990.0, + 878.0, + 523.0 + ], + "category_id": 6, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1072.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 27, + "annotations": [ + { + "segmentation": [], + "area": 502884.0, + "iscrowd": 0, + "image_id": 27, + "bbox": [ + 746.0, + 1211.0, + 916.0, + 549.0 + ], + "category_id": 3, + "id": 0 + }, + { + "segmentation": [], + "area": 516912.0, + "iscrowd": 0, + "image_id": 27, + "bbox": [ + 1905.0, + 1465.0, + 968.0, + 534.0 + ], + "category_id": 2, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1074.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 28, + "annotations": [ + { + "segmentation": [], + "area": 1679288.0, + "iscrowd": 0, + "image_id": 28, + "bbox": [ + 1127.0, + 1319.0, + 1742.0, + 964.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1077.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 29, + "annotations": [ + { + "segmentation": [], + "area": 688200.0, + "iscrowd": 0, + "image_id": 29, + "bbox": [ + 308.0, + 1282.0, + 1110.0, + 620.0 + ], + "category_id": 6, + "id": 0 + }, + { + "segmentation": [], + "area": 706992.0, + "iscrowd": 0, + "image_id": 29, + "bbox": [ + 1700.0, + 1342.0, + 1133.0, + 624.0 + ], + "category_id": 1, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1081.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 30, + "annotations": [ + { + "segmentation": [], + "area": 282744.0, + "iscrowd": 0, + "image_id": 30, + "bbox": [ + 1475.0, + 1282.0, + 714.0, + 396.0 + ], + "category_id": 4, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1082.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 31, + "annotations": [ + { + "segmentation": [], + "area": 511038.0, + "iscrowd": 0, + "image_id": 31, + "bbox": [ + 996.0, + 579.0, + 957.0, + 534.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 512732.0, + "iscrowd": 0, + "image_id": 31, + "bbox": [ + 2118.0, + 601.0, + 946.0, + 542.0 + ], + "category_id": 4, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1086.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 32, + "annotations": [ + { + "segmentation": [], + "area": 202188.0, + "iscrowd": 0, + "image_id": 32, + "bbox": [ + 716.0, + 975.0, + 609.0, + 332.0 + ], + "category_id": 4, + "id": 0 + }, + { + "segmentation": [], + "area": 202272.0, + "iscrowd": 0, + "image_id": 32, + "bbox": [ + 1471.0, + 971.0, + 602.0, + 336.0 + ], + "category_id": 2, + "id": 1 + }, + { + "segmentation": [], + "area": 204336.0, + "iscrowd": 0, + "image_id": 32, + "bbox": [ + 2175.0, + 1005.0, + 594.0, + 344.0 + ], + "category_id": 1, + "id": 2 + }, + { + "segmentation": [], + "area": 216118.0, + "iscrowd": 0, + "image_id": 32, + "bbox": [ + 2878.0, + 990.0, + 602.0, + 359.0 + ], + "category_id": 3, + "id": 3 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1088.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 33, + "annotations": [ + { + "segmentation": [], + "area": 332958.0, + "iscrowd": 0, + "image_id": 33, + "bbox": [ + 1232.0, + 440.0, + 789.0, + 422.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 241980.0, + "iscrowd": 0, + "image_id": 33, + "bbox": [ + 1326.0, + 1525.0, + 654.0, + 370.0 + ], + "category_id": 2, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1090.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 34, + "annotations": [ + { + "segmentation": [], + "area": 249010.0, + "iscrowd": 0, + "image_id": 34, + "bbox": [ + 1920.0, + 784.0, + 673.0, + 370.0 + ], + "category_id": 1, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1092.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 35, + "annotations": [ + { + "segmentation": [], + "area": 466446.0, + "iscrowd": 0, + "image_id": 35, + "bbox": [ + 424.0, + 1293.0, + 867.0, + 538.0 + ], + "category_id": 4, + "id": 0 + }, + { + "segmentation": [], + "area": 459240.0, + "iscrowd": 0, + "image_id": 35, + "bbox": [ + 1636.0, + 1521.0, + 890.0, + 516.0 + ], + "category_id": 5, + "id": 1 + }, + { + "segmentation": [], + "area": 378504.0, + "iscrowd": 0, + "image_id": 35, + "bbox": [ + 2481.0, + 1028.0, + 751.0, + 504.0 + ], + "category_id": 3, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1094.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 36, + "annotations": [ + { + "segmentation": [], + "area": 577753.0, + "iscrowd": 0, + "image_id": 36, + "bbox": [ + 1378.0, + 1035.0, + 991.0, + 583.0 + ], + "category_id": 4, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1097.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 37, + "annotations": [ + { + "segmentation": [], + "area": 733425.0, + "iscrowd": 0, + "image_id": 37, + "bbox": [ + 1326.0, + 642.0, + 1155.0, + 635.0 + ], + "category_id": 5, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1099.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 38, + "annotations": [ + { + "segmentation": [], + "area": 628296.0, + "iscrowd": 0, + "image_id": 38, + "bbox": [ + 1112.0, + 556.0, + 1114.0, + 564.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1101.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 39, + "annotations": [ + { + "segmentation": [], + "area": 461664.0, + "iscrowd": 0, + "image_id": 39, + "bbox": [ + 1015.0, + 1072.0, + 916.0, + 504.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1103.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 40, + "annotations": [ + { + "segmentation": [], + "area": 248069.0, + "iscrowd": 0, + "image_id": 40, + "bbox": [ + 1475.0, + 541.0, + 691.0, + 359.0 + ], + "category_id": 6, + "id": 0 + }, + { + "segmentation": [], + "area": 438084.0, + "iscrowd": 0, + "image_id": 40, + "bbox": [ + 1168.0, + 1880.0, + 849.0, + 516.0 + ], + "category_id": 5, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1104.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 41, + "annotations": [ + { + "segmentation": [], + "area": 225036.0, + "iscrowd": 0, + "image_id": 41, + "bbox": [ + 1715.0, + 493.0, + 684.0, + 329.0 + ], + "category_id": 5, + "id": 0 + }, + { + "segmentation": [], + "area": 329724.0, + "iscrowd": 0, + "image_id": 41, + "bbox": [ + 1632.0, + 1783.0, + 774.0, + 426.0 + ], + "category_id": 1, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1105.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 42, + "annotations": [ + { + "segmentation": [], + "area": 990560.0, + "iscrowd": 0, + "image_id": 42, + "bbox": [ + 1090.0, + 1016.0, + 1312.0, + 755.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1106.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 43, + "annotations": [ + { + "segmentation": [], + "area": 720720.0, + "iscrowd": 0, + "image_id": 43, + "bbox": [ + 1202.0, + 1076.0, + 1155.0, + 624.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1109.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 44, + "annotations": [ + { + "segmentation": [], + "area": 765700.0, + "iscrowd": 0, + "image_id": 44, + "bbox": [ + 1053.0, + 878.0, + 1178.0, + 650.0 + ], + "category_id": 3, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1110.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 45, + "annotations": [ + { + "segmentation": [], + "area": 757986.0, + "iscrowd": 0, + "image_id": 45, + "bbox": [ + 686.0, + 743.0, + 1159.0, + 654.0 + ], + "category_id": 3, + "id": 0 + }, + { + "segmentation": [], + "area": 754882.0, + "iscrowd": 0, + "image_id": 45, + "bbox": [ + 1920.0, + 792.0, + 1174.0, + 643.0 + ], + "category_id": 1, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1111.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 46, + "annotations": [ + { + "segmentation": [], + "area": 589824.0, + "iscrowd": 0, + "image_id": 46, + "bbox": [ + 1890.0, + 867.0, + 1024.0, + 576.0 + ], + "category_id": 6, + "id": 0 + }, + { + "segmentation": [], + "area": 608069.0, + "iscrowd": 0, + "image_id": 46, + "bbox": [ + 671.0, + 874.0, + 1043.0, + 583.0 + ], + "category_id": 2, + "id": 1 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1114.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 47, + "annotations": [ + { + "segmentation": [], + "area": 504952.0, + "iscrowd": 0, + "image_id": 47, + "bbox": [ + 1535.0, + 1177.0, + 994.0, + 508.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1116.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 48, + "annotations": [ + { + "segmentation": [], + "area": 521954.0, + "iscrowd": 0, + "image_id": 48, + "bbox": [ + 1539.0, + 1458.0, + 998.0, + 523.0 + ], + "category_id": 5, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1120.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 49, + "annotations": [ + { + "segmentation": [], + "area": 934744.0, + "iscrowd": 0, + "image_id": 49, + "bbox": [ + 1236.0, + 1274.0, + 1324.0, + 706.0 + ], + "category_id": 3, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1122.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 50, + "annotations": [ + { + "segmentation": [], + "area": 546878.0, + "iscrowd": 0, + "image_id": 50, + "bbox": [ + 1479.0, + 949.0, + 1009.0, + 542.0 + ], + "category_id": 5, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1125.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 51, + "annotations": [ + { + "segmentation": [], + "area": 271410.0, + "iscrowd": 0, + "image_id": 51, + "bbox": [ + 978.0, + 930.0, + 654.0, + 415.0 + ], + "category_id": 1, + "id": 0 + }, + { + "segmentation": [], + "area": 392830.0, + "iscrowd": 0, + "image_id": 51, + "bbox": [ + 1198.0, + 1394.0, + 815.0, + 482.0 + ], + "category_id": 6, + "id": 1 + }, + { + "segmentation": [], + "area": 364320.0, + "iscrowd": 0, + "image_id": 51, + "bbox": [ + 2406.0, + 1252.0, + 792.0, + 460.0 + ], + "category_id": 2, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1129.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 52, + "annotations": [ + { + "segmentation": [], + "area": 396792.0, + "iscrowd": 0, + "image_id": 52, + "bbox": [ + 1408.0, + 1772.0, + 792.0, + 501.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1130.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 53, + "annotations": [ + { + "segmentation": [], + "area": 355605.0, + "iscrowd": 0, + "image_id": 53, + "bbox": [ + 1516.0, + 1708.0, + 755.0, + 471.0 + ], + "category_id": 1, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1132.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 54, + "annotations": [ + { + "segmentation": [], + "area": 122250.0, + "iscrowd": 0, + "image_id": 54, + "bbox": [ + 2751.0, + 1005.0, + 489.0, + 250.0 + ], + "category_id": 1, + "id": 0 + }, + { + "segmentation": [], + "area": 467039.0, + "iscrowd": 0, + "image_id": 54, + "bbox": [ + 2283.0, + 1278.0, + 893.0, + 523.0 + ], + "category_id": 4, + "id": 1 + }, + { + "segmentation": [], + "area": 1040440.0, + "iscrowd": 0, + "image_id": 54, + "bbox": [ + 174.0, + 1663.0, + 1406.0, + 740.0 + ], + "category_id": 5, + "id": 2 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1133.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 55, + "annotations": [ + { + "segmentation": [], + "area": 958740.0, + "iscrowd": 0, + "image_id": 55, + "bbox": [ + 1352.0, + 1192.0, + 1140.0, + 841.0 + ], + "category_id": 1, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1135.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 56, + "annotations": [ + { + "segmentation": [], + "area": 217195.0, + "iscrowd": 0, + "image_id": 56, + "bbox": [ + 1801.0, + 1233.0, + 605.0, + 359.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1137.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 57, + "annotations": [ + { + "segmentation": [], + "area": 405822.0, + "iscrowd": 0, + "image_id": 57, + "bbox": [ + 1879.0, + 1136.0, + 849.0, + 478.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1140.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 58, + "annotations": [ + { + "segmentation": [], + "area": 224076.0, + "iscrowd": 0, + "image_id": 58, + "bbox": [ + 1722.0, + 594.0, + 789.0, + 284.0 + ], + "category_id": 6, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1141.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 59, + "annotations": [ + { + "segmentation": [], + "area": 215556.0, + "iscrowd": 0, + "image_id": 59, + "bbox": [ + 1793.0, + 665.0, + 781.0, + 276.0 + ], + "category_id": 2, + "id": 0 + } + ] + }, + { + "license": 1, + "file_name": "DSCF1142.jpg", + "coco_url": "none", + "height": 2736, + "width": 3648, + "date_captured": "none", + "flickr_url": "none", + "id": 60, + "annotations": [ + { + "segmentation": [], + "area": 343768.0, + "iscrowd": 0, + "image_id": 60, + "bbox": [ + 914.0, + 1200.0, + 886.0, + 388.0 + ], + "category_id": 2, + "id": 0 + }, + { + "segmentation": [], + "area": 340664.0, + "iscrowd": 0, + "image_id": 60, + "bbox": [ + 2010.0, + 1211.0, + 878.0, + 388.0 + ], + "category_id": 1, + "id": 1 + } + ] + } + ], + "categories": [ + { + "supercategory": "bus", + "id": 1, + "name": "green" + }, + { + "supercategory": "bus", + "id": 2, + "name": "yellow" + }, + { + "supercategory": "bus", + "id": 3, + "name": "white" + }, + { + "supercategory": "bus", + "id": 4, + "name": "gray" + }, + { + "supercategory": "bus", + "id": 5, + "name": "blue" + }, + { + "supercategory": "bus", + "id": 6, + "name": "red" + } + ], + "segment_info": [] +} \ No newline at end of file diff --git a/data/originalData/busProjectTest.py b/data/originalData/busProjectTest.py new file mode 100644 index 0000000..4c1ae78 --- /dev/null +++ b/data/originalData/busProjectTest.py @@ -0,0 +1,190 @@ +import os +import sys +import matplotlib +import matplotlib.pyplot as plt +import matplotlib.patches as patches +import numpy as np +import ast + +import imageio + + +fontdict = {'fontsize':15, 'weight':'bold'} +plt.switch_backend('Qt5Agg') + +class IMAGE: + + def __init__(self): + self.ROIS = [] + + def set_image(self, im): + self.I = imageio.imread(im) + self.imShape = self.I.shape + + def clear_ROIS(self): + self.ROIS = [] + + def add_ROI(self, pos): + self.ROIS.append(pos) + + def show_ROI(self, title, edgecolor, numGT, text, saveDir = None): + fig, ax = plt.subplots(1) + ax.imshow(self.I) + if(not isinstance(edgecolor,list) and len(self.ROIS) > 0): + edgecolor = [edgecolor] * len(self.ROIS) + for i in range(0,numGT): + ROI = self.ROIS[i] + rect = patches.Rectangle((ROI[0], ROI[1]), ROI[2], ROI[3], linewidth = 1, edgecolor = edgecolor[i], facecolor='none') + ax.add_patch(rect) + for i in range(numGT,len(self.ROIS)): + ROI = self.ROIS[i] + rect = patches.Rectangle((ROI[0], ROI[1]), ROI[2], ROI[3], linewidth = 1, edgecolor = edgecolor[i], facecolor='none', linestyle = '--') + ax.add_patch(rect) + if(saveDir is None): + ax.text(15,160,text, fontdict = fontdict, bbox={'facecolor':'yellow', 'edgecolor':'yellow','alpha':0.5, 'pad':2}) + else: + ax.text(15, 300, text, fontdict=fontdict,bbox={'facecolor': 'yellow', 'edgecolor': 'yellow', 'alpha': 0.5, 'pad': 2}) + plt.title(title) + if(not saveDir is None): + plt.savefig(os.path.join(saveDir, title), dpi = 500) + plt.close() + + def close(self): + plt.close() + +def IOU(boxAList, boxBList): + Th = 0.69 + iou = [] + matches = {} + tp = 0 + fp = len(boxBList) + missed = len(boxAList) + for i in range(len(boxAList)): + boxA = boxAList[i][:4] + iou_ = [] + for j in range(len(boxBList)): + boxB = boxBList[j][:4] + if(not ((boxB[0] <= boxA[0] <= boxB[0] + boxB[2]) or (boxA[0] <= boxB[0] <= boxA[0] + boxA[2]))): + iou_.append(0.0) + continue + xA = max(boxA[0], boxB[0]) + yA = max(boxA[1], boxB[1]) + xB = min(boxA[0] + boxA[2], boxB[0] + boxB[2]) + yB = min(boxA[1] + boxA[3], boxB[1] + boxB[3]) + interArea = (xB - xA + 1) * (yB - yA + 1) + boxAArea = (boxA[2] + 1)*(boxA[3] + 1) + boxBArea = (boxB[2] + 1)*(boxB[3] + 1) + iou_.append(interArea / float(boxAArea + boxBArea - interArea)) + maxIou = max(iou_) + maxIouIndex = iou_.index(max(iou_)) + iou.append(maxIou) + if (maxIouIndex in matches and maxIou > iou[matches[maxIouIndex]]): + if (iou[matches[maxIouIndex]] > Th and boxAList[matches[maxIouIndex]][4] == boxBList[maxIouIndex][4]): + pass + elif(maxIou > Th and boxAList[i][4] == boxBList[maxIouIndex][4]): + tp += 1 + missed -= 1 + fp -= 1 + matches[maxIouIndex] = i + if(not maxIouIndex in matches): + matches[maxIouIndex] = i + if(maxIou > Th and boxAList[i][4] == boxBList[maxIouIndex][4]): + tp += 1 + missed -= 1 + fp -= 1 + return tp, fp, missed, iou + +def runTest(annFileNameGT, myAnnFileName, busDir , saveDir = None, elapsed = None): + + image = IMAGE() + objectsColors = {'g':'1', 'y':'2', 'w':'3', 's':'4', 'b':'5', 'r':'6'} + objectsColorsInv = {v: k for k, v in objectsColors.items()} + objectsColorsForShow = {'g':'g', 'y':'y', 'w':'w', 's':'tab:gray', 'b':'b', 'r':'r'} + + writtenAnnsLines = {} + annFileEstimations = open(myAnnFileName, 'r') + annFileGT = open(annFileNameGT, 'r') + writtenAnnsLines['Ground_Truth'] = (annFileGT.readlines()) + writtenAnnsLines['Estimation'] = (annFileEstimations.readlines()) + + TP = 0 + FP = 0 + MISS = 0 + + for i in range(len(writtenAnnsLines['Ground_Truth'])): + + lineGT = writtenAnnsLines['Ground_Truth'][i].replace(' ','') + colors = [] + imName = lineGT.split(':')[0] + lineE = [x for x in writtenAnnsLines['Estimation'] if imName == x.split(':')[0]] + if(len(lineE) == 0): + lineE = imName + ':' + else: + lineE = lineE[0] + bus = os.path.join(busDir, imName) + image.set_image(bus) + image.clear_ROIS() + annsGT = lineGT[lineGT.index(':') + 1:].replace('\n', '') + annsE = lineE[lineE.index(':') + 1:].replace('\n', '') + annsGT = ast.literal_eval(annsGT) + if (not isinstance(annsGT, tuple)): + annsGT = [annsGT] + for ann in annsGT: + image.add_ROI(ann[:4]) + colorTag = objectsColorsInv[str(ann[4])] + colors.append(objectsColorsForShow[colorTag]) + numGT = len(annsGT) + if('[' in lineE): + annsE = ast.literal_eval(annsE) + if (not isinstance(annsE, tuple)): + annsE = [annsE] + for ann in annsE: + image.add_ROI(ann[:4]) + colorTag = objectsColorsInv[str(ann[4])] + colors.append(objectsColorsForShow[colorTag]) + tp, fp, missed, iou = IOU(annsGT, annsE) + else: + tp = 0 + fp = 0 + numGT = 0 + missed = len(annsGT) + iou = [] + TP += tp + FP += fp + MISS += missed + print('Image : {}, TP: {} FP: {} MISSED : {}'.format(imName, tp, fp, missed)) + iouStr = ','.join(['{0:.2f}'.format(x) for x in iou]) + text = 'IOU Scores : ' + iouStr + '\nTP = {}, FP = {}, Missed = {} '.format(tp, fp, missed) + image.show_ROI(edgecolor = colors, title = imName, numGT = numGT , text = text, saveDir = saveDir) + + if(TP == 0): + F1Score = 0 + else: + precision = TP/(TP + FP) + recall = TP/(TP + MISS) + F1Score = 2*(precision * recall)/(precision + recall) + strToWrite = 'Total detections = {}/{}\nTotal False Positives = {}\nTotal missed = {}'.format(TP, TP+MISS, FP, MISS) + strToWrite += '\nF1 SCORE : {0:.3f}'.format(F1Score) + if(not elapsed is None): + strToWrite += '\nTime elapsed : {0:.2f} seconds'.format(elapsed) + fig, ax = plt.subplots(1) + plt.title('Results', fontdict = {'fontsize':20}) + im = np.zeros((10,26,3), dtype=np.uint8) + im[:,:,2] = 221 + im[:,:,1] = 114 + im[:,:,0] = 102 + ax.imshow(im) + ax.text(4,7, strToWrite, style='italic', fontdict = {'fontsize':50, 'weight':'bold'}) + mng = plt.get_current_fig_manager() + mng.window.showMaximized() + plt.show() + plt.close() + FIG, ax = plt.subplots(1) + plt.title('Results', fontdict = {'fontsize':20}) + ax.imshow(im) + ax.text(2,8, strToWrite, style='italic', fontdict = {'fontsize':20, 'weight':'bold'}) + if(saveDir is None): + saveDir = os.path.join(os.getcwd(), 'Output') + if(not os.path.exists(saveDir)): + os.mkdir(saveDir) + plt.savefig(os.path.join(saveDir,'Results.png'), dpi = 600) diff --git a/data/originalData/pictures/DSCF1013.JPG b/data/originalData/pictures/DSCF1013.JPG new file mode 100644 index 0000000..15949bb Binary files /dev/null and b/data/originalData/pictures/DSCF1013.JPG differ diff --git a/data/originalData/pictures/DSCF1015.JPG b/data/originalData/pictures/DSCF1015.JPG new file mode 100644 index 0000000..7506f8f Binary files /dev/null and b/data/originalData/pictures/DSCF1015.JPG differ diff --git a/data/originalData/pictures/DSCF1016.JPG b/data/originalData/pictures/DSCF1016.JPG new file mode 100644 index 0000000..8070b77 Binary files /dev/null and b/data/originalData/pictures/DSCF1016.JPG differ diff --git a/data/originalData/pictures/DSCF1017.JPG b/data/originalData/pictures/DSCF1017.JPG new file mode 100644 index 0000000..1a70b6a Binary files /dev/null and b/data/originalData/pictures/DSCF1017.JPG differ diff --git a/data/originalData/pictures/DSCF1021.JPG b/data/originalData/pictures/DSCF1021.JPG new file mode 100644 index 0000000..60022a1 Binary files /dev/null and b/data/originalData/pictures/DSCF1021.JPG differ diff --git a/data/originalData/pictures/DSCF1023.JPG b/data/originalData/pictures/DSCF1023.JPG new file mode 100644 index 0000000..990512a Binary files /dev/null and b/data/originalData/pictures/DSCF1023.JPG differ diff --git a/data/originalData/pictures/DSCF1025.JPG b/data/originalData/pictures/DSCF1025.JPG new file mode 100644 index 0000000..22713ef Binary files /dev/null and b/data/originalData/pictures/DSCF1025.JPG differ diff --git a/data/originalData/pictures/DSCF1029.JPG b/data/originalData/pictures/DSCF1029.JPG new file mode 100644 index 0000000..e54af20 Binary files /dev/null and b/data/originalData/pictures/DSCF1029.JPG differ diff --git a/data/originalData/pictures/DSCF1032.JPG b/data/originalData/pictures/DSCF1032.JPG new file mode 100644 index 0000000..51e61f8 Binary files /dev/null and b/data/originalData/pictures/DSCF1032.JPG differ diff --git a/data/originalData/pictures/DSCF1037.JPG b/data/originalData/pictures/DSCF1037.JPG new file mode 100644 index 0000000..f460630 Binary files /dev/null and b/data/originalData/pictures/DSCF1037.JPG differ diff --git a/data/originalData/pictures/DSCF1038.JPG b/data/originalData/pictures/DSCF1038.JPG new file mode 100644 index 0000000..4c73ac7 Binary files /dev/null and b/data/originalData/pictures/DSCF1038.JPG differ diff --git a/data/originalData/pictures/DSCF1040.JPG b/data/originalData/pictures/DSCF1040.JPG new file mode 100644 index 0000000..cf557e5 Binary files /dev/null and b/data/originalData/pictures/DSCF1040.JPG differ diff --git a/data/originalData/pictures/DSCF1042.JPG b/data/originalData/pictures/DSCF1042.JPG new file mode 100644 index 0000000..413bbaa Binary files /dev/null and b/data/originalData/pictures/DSCF1042.JPG differ diff --git a/data/originalData/pictures/DSCF1044.JPG b/data/originalData/pictures/DSCF1044.JPG new file mode 100644 index 0000000..8cf8153 Binary files /dev/null and b/data/originalData/pictures/DSCF1044.JPG differ diff --git a/data/originalData/pictures/DSCF1048.JPG b/data/originalData/pictures/DSCF1048.JPG new file mode 100644 index 0000000..cd3db1e Binary files /dev/null and b/data/originalData/pictures/DSCF1048.JPG differ diff --git a/data/originalData/pictures/DSCF1049.JPG b/data/originalData/pictures/DSCF1049.JPG new file mode 100644 index 0000000..034cf43 Binary files /dev/null and b/data/originalData/pictures/DSCF1049.JPG differ diff --git a/data/originalData/pictures/DSCF1050.JPG b/data/originalData/pictures/DSCF1050.JPG new file mode 100644 index 0000000..47b7b9e Binary files /dev/null and b/data/originalData/pictures/DSCF1050.JPG differ diff --git a/data/originalData/pictures/DSCF1053.JPG b/data/originalData/pictures/DSCF1053.JPG new file mode 100644 index 0000000..834bec5 Binary files /dev/null and b/data/originalData/pictures/DSCF1053.JPG differ diff --git a/data/originalData/pictures/DSCF1056.JPG b/data/originalData/pictures/DSCF1056.JPG new file mode 100644 index 0000000..139b036 Binary files /dev/null and b/data/originalData/pictures/DSCF1056.JPG differ diff --git a/data/originalData/pictures/DSCF1059.JPG b/data/originalData/pictures/DSCF1059.JPG new file mode 100644 index 0000000..ba7c631 Binary files /dev/null and b/data/originalData/pictures/DSCF1059.JPG differ diff --git a/data/originalData/pictures/DSCF1061.JPG b/data/originalData/pictures/DSCF1061.JPG new file mode 100644 index 0000000..ea3ef02 Binary files /dev/null and b/data/originalData/pictures/DSCF1061.JPG differ diff --git a/data/originalData/pictures/DSCF1064.JPG b/data/originalData/pictures/DSCF1064.JPG new file mode 100644 index 0000000..971f7cc Binary files /dev/null and b/data/originalData/pictures/DSCF1064.JPG differ diff --git a/data/originalData/pictures/DSCF1065.JPG b/data/originalData/pictures/DSCF1065.JPG new file mode 100644 index 0000000..83ad467 Binary files /dev/null and b/data/originalData/pictures/DSCF1065.JPG differ diff --git a/data/originalData/pictures/DSCF1066.JPG b/data/originalData/pictures/DSCF1066.JPG new file mode 100644 index 0000000..9a0617d Binary files /dev/null and b/data/originalData/pictures/DSCF1066.JPG differ diff --git a/data/originalData/pictures/DSCF1068.JPG b/data/originalData/pictures/DSCF1068.JPG new file mode 100644 index 0000000..d66ea7c Binary files /dev/null and b/data/originalData/pictures/DSCF1068.JPG differ diff --git a/data/originalData/pictures/DSCF1070.JPG b/data/originalData/pictures/DSCF1070.JPG new file mode 100644 index 0000000..8667b88 Binary files /dev/null and b/data/originalData/pictures/DSCF1070.JPG differ diff --git a/data/originalData/pictures/DSCF1072.JPG b/data/originalData/pictures/DSCF1072.JPG new file mode 100644 index 0000000..d8fe3e1 Binary files /dev/null and b/data/originalData/pictures/DSCF1072.JPG differ diff --git a/data/originalData/pictures/DSCF1074.JPG b/data/originalData/pictures/DSCF1074.JPG new file mode 100644 index 0000000..c2d98e3 Binary files /dev/null and b/data/originalData/pictures/DSCF1074.JPG differ diff --git a/data/originalData/pictures/DSCF1077.JPG b/data/originalData/pictures/DSCF1077.JPG new file mode 100644 index 0000000..7c28ee2 Binary files /dev/null and b/data/originalData/pictures/DSCF1077.JPG differ diff --git a/data/originalData/pictures/DSCF1081.JPG b/data/originalData/pictures/DSCF1081.JPG new file mode 100644 index 0000000..f0d44f1 Binary files /dev/null and b/data/originalData/pictures/DSCF1081.JPG differ diff --git a/data/originalData/pictures/DSCF1082.JPG b/data/originalData/pictures/DSCF1082.JPG new file mode 100644 index 0000000..979cdf6 Binary files /dev/null and b/data/originalData/pictures/DSCF1082.JPG differ diff --git a/data/originalData/pictures/DSCF1086.JPG b/data/originalData/pictures/DSCF1086.JPG new file mode 100644 index 0000000..f2adc9d Binary files /dev/null and b/data/originalData/pictures/DSCF1086.JPG differ diff --git a/data/originalData/pictures/DSCF1088.JPG b/data/originalData/pictures/DSCF1088.JPG new file mode 100644 index 0000000..95277e9 Binary files /dev/null and b/data/originalData/pictures/DSCF1088.JPG differ diff --git a/data/originalData/pictures/DSCF1090.JPG b/data/originalData/pictures/DSCF1090.JPG new file mode 100644 index 0000000..eb5dd85 Binary files /dev/null and b/data/originalData/pictures/DSCF1090.JPG differ diff --git a/data/originalData/pictures/DSCF1092.JPG b/data/originalData/pictures/DSCF1092.JPG new file mode 100644 index 0000000..111ef52 Binary files /dev/null and b/data/originalData/pictures/DSCF1092.JPG differ diff --git a/data/originalData/pictures/DSCF1094.JPG b/data/originalData/pictures/DSCF1094.JPG new file mode 100644 index 0000000..6dfda85 Binary files /dev/null and b/data/originalData/pictures/DSCF1094.JPG differ diff --git a/data/originalData/pictures/DSCF1097.JPG b/data/originalData/pictures/DSCF1097.JPG new file mode 100644 index 0000000..c95008a Binary files /dev/null and b/data/originalData/pictures/DSCF1097.JPG differ diff --git a/data/originalData/pictures/DSCF1099.JPG b/data/originalData/pictures/DSCF1099.JPG new file mode 100644 index 0000000..c706cde Binary files /dev/null and b/data/originalData/pictures/DSCF1099.JPG differ diff --git a/data/originalData/pictures/DSCF1101.JPG b/data/originalData/pictures/DSCF1101.JPG new file mode 100644 index 0000000..5860c93 Binary files /dev/null and b/data/originalData/pictures/DSCF1101.JPG differ diff --git a/data/originalData/pictures/DSCF1103.JPG b/data/originalData/pictures/DSCF1103.JPG new file mode 100644 index 0000000..b7964b2 Binary files /dev/null and b/data/originalData/pictures/DSCF1103.JPG differ diff --git a/data/originalData/pictures/DSCF1104.JPG b/data/originalData/pictures/DSCF1104.JPG new file mode 100644 index 0000000..ecf7e90 Binary files /dev/null and b/data/originalData/pictures/DSCF1104.JPG differ diff --git a/data/originalData/pictures/DSCF1105.JPG b/data/originalData/pictures/DSCF1105.JPG new file mode 100644 index 0000000..2648218 Binary files /dev/null and b/data/originalData/pictures/DSCF1105.JPG differ diff --git a/data/originalData/pictures/DSCF1106.JPG b/data/originalData/pictures/DSCF1106.JPG new file mode 100644 index 0000000..bfde090 Binary files /dev/null and b/data/originalData/pictures/DSCF1106.JPG differ diff --git a/data/originalData/pictures/DSCF1109.JPG b/data/originalData/pictures/DSCF1109.JPG new file mode 100644 index 0000000..d818121 Binary files /dev/null and b/data/originalData/pictures/DSCF1109.JPG differ diff --git a/data/originalData/pictures/DSCF1110.JPG b/data/originalData/pictures/DSCF1110.JPG new file mode 100644 index 0000000..590d1fe Binary files /dev/null and b/data/originalData/pictures/DSCF1110.JPG differ diff --git a/data/originalData/pictures/DSCF1111.JPG b/data/originalData/pictures/DSCF1111.JPG new file mode 100644 index 0000000..4c86e8a Binary files /dev/null and b/data/originalData/pictures/DSCF1111.JPG differ diff --git a/data/originalData/pictures/DSCF1114.JPG b/data/originalData/pictures/DSCF1114.JPG new file mode 100644 index 0000000..94c6d85 Binary files /dev/null and b/data/originalData/pictures/DSCF1114.JPG differ diff --git a/data/originalData/pictures/DSCF1116.JPG b/data/originalData/pictures/DSCF1116.JPG new file mode 100644 index 0000000..84ed271 Binary files /dev/null and b/data/originalData/pictures/DSCF1116.JPG differ diff --git a/data/originalData/pictures/DSCF1120.JPG b/data/originalData/pictures/DSCF1120.JPG new file mode 100644 index 0000000..8ce0252 Binary files /dev/null and b/data/originalData/pictures/DSCF1120.JPG differ diff --git a/data/originalData/pictures/DSCF1122.JPG b/data/originalData/pictures/DSCF1122.JPG new file mode 100644 index 0000000..b1d6d77 Binary files /dev/null and b/data/originalData/pictures/DSCF1122.JPG differ diff --git a/data/originalData/pictures/DSCF1125.JPG b/data/originalData/pictures/DSCF1125.JPG new file mode 100644 index 0000000..3c1b907 Binary files /dev/null and b/data/originalData/pictures/DSCF1125.JPG differ diff --git a/data/originalData/pictures/DSCF1129.JPG b/data/originalData/pictures/DSCF1129.JPG new file mode 100644 index 0000000..51c4329 Binary files /dev/null and b/data/originalData/pictures/DSCF1129.JPG differ diff --git a/data/originalData/pictures/DSCF1130.JPG b/data/originalData/pictures/DSCF1130.JPG new file mode 100644 index 0000000..2cafd00 Binary files /dev/null and b/data/originalData/pictures/DSCF1130.JPG differ diff --git a/data/originalData/pictures/DSCF1132.JPG b/data/originalData/pictures/DSCF1132.JPG new file mode 100644 index 0000000..e694119 Binary files /dev/null and b/data/originalData/pictures/DSCF1132.JPG differ diff --git a/data/originalData/pictures/DSCF1133.JPG b/data/originalData/pictures/DSCF1133.JPG new file mode 100644 index 0000000..afd3238 Binary files /dev/null and b/data/originalData/pictures/DSCF1133.JPG differ diff --git a/data/originalData/pictures/DSCF1135.JPG b/data/originalData/pictures/DSCF1135.JPG new file mode 100644 index 0000000..0896671 Binary files /dev/null and b/data/originalData/pictures/DSCF1135.JPG differ diff --git a/data/originalData/pictures/DSCF1137.JPG b/data/originalData/pictures/DSCF1137.JPG new file mode 100644 index 0000000..570b7a9 Binary files /dev/null and b/data/originalData/pictures/DSCF1137.JPG differ diff --git a/data/originalData/pictures/DSCF1140.JPG b/data/originalData/pictures/DSCF1140.JPG new file mode 100644 index 0000000..971dfb9 Binary files /dev/null and b/data/originalData/pictures/DSCF1140.JPG differ diff --git a/data/originalData/pictures/DSCF1141.JPG b/data/originalData/pictures/DSCF1141.JPG new file mode 100644 index 0000000..feb28c4 Binary files /dev/null and b/data/originalData/pictures/DSCF1141.JPG differ diff --git a/data/originalData/pictures/DSCF1142.JPG b/data/originalData/pictures/DSCF1142.JPG new file mode 100644 index 0000000..cb155fc Binary files /dev/null and b/data/originalData/pictures/DSCF1142.JPG differ diff --git a/data/originalData/pictures/originalAnnotationsTrain.txt b/data/originalData/pictures/originalAnnotationsTrain.txt new file mode 100644 index 0000000..f1b959d --- /dev/null +++ b/data/originalData/pictures/originalAnnotationsTrain.txt @@ -0,0 +1,60 @@ +DSCF1013.JPG:[1217,1690,489,201,1],[1774,1619,475,224,2],[2313,1566,460,228,3],[1284,1832,497,231,4],[1879,1798,486,228,5],[2429,1742,475,228,6] +DSCF1015.JPG:[641,1342,1181,892,3],[2053,1022,1122,735,6] +DSCF1016.JPG:[1067,1843,1114,613,4],[1954,1278,1021,561,6],[2392,717,964,635,3] +DSCF1017.JPG:[1834,698,789,422,4] +DSCF1021.JPG:[1991,755,923,546,5] +DSCF1023.JPG:[1909,1166,785,452,2] +DSCF1025.JPG:[985,1570,1252,710,6] +DSCF1029.JPG:[129,1648,1271,733,6],[1456,1076,1122,834,2],[2552,826,1058,804,1] +DSCF1032.JPG:[144,1200,983,467,5],[2339,1125,916,456,6] +DSCF1037.JPG:[1210,1712,1469,643,1] +DSCF1038.JPG:[1210,1764,1754,796,2] +DSCF1040.JPG:[462,1813,976,546,2],[1445,1791,871,482,1],[2305,1779,785,463,4] +DSCF1042.JPG:[2021,1682,1013,504,5] +DSCF1044.JPG:[1460,1200,946,523,6] +DSCF1048.JPG:[443,1230,665,314,4],[1498,1181,665,295,5],[2511,1099,703,310,3] +DSCF1049.JPG:[480,998,789,388,4],[1718,1192,740,396,5],[2758,1364,706,347,3] +DSCF1050.JPG:[454,766,804,366,5],[1767,807,792,366,3] +DSCF1053.JPG:[925,1536,1006,516,1],[2010,1510,1013,523,6] +DSCF1056.JPG:[469,957,1234,632,2],[1700,953,1219,662,6] +DSCF1059.JPG:[1221,994,1103,706,2] +DSCF1061.JPG:[488,1648,1361,792,6],[1191,1203,1144,632,2] +DSCF1064.JPG:[2399,358,811,519,3],[585,740,927,579,2] +DSCF1065.JPG:[705,1031,811,306,5],[2193,908,766,306,1] +DSCF1066.JPG:[1019,1121,718,332,1],[2025,1121,695,321,5] +DSCF1068.JPG:[750,343,1316,501,5],[2459,1533,957,527,1] +DSCF1070.JPG:[1617,1413,1028,583,2],[1528,990,878,523,6] +DSCF1072.JPG:[746,1211,916,549,3],[1905,1465,968,534,2] +DSCF1074.JPG:[1127,1319,1742,964,2] +DSCF1077.JPG:[308,1282,1110,620,6],[1700,1342,1133,624,1] +DSCF1081.JPG:[1475,1282,714,396,4] +DSCF1082.JPG:[996,579,957,534,5],[2118,601,946,542,4] +DSCF1086.JPG:[716,975,609,332,4],[1471,971,602,336,2],[2175,1005,594,344,1],[2878,990,602,359,3] +DSCF1088.JPG:[1232,440,789,422,5],[1326,1525,654,370,2] +DSCF1090.JPG:[1920,784,673,370,1] +DSCF1092.JPG:[424,1293,867,538,4],[1636,1521,890,516,5],[2481,1028,751,504,3] +DSCF1094.JPG:[1378,1035,991,583,4] +DSCF1097.JPG:[1326,642,1155,635,5] +DSCF1099.JPG:[1112,556,1114,564,6] +DSCF1101.JPG:[1015,1072,916,504,2] +DSCF1103.JPG:[1475,541,691,359,6],[1168,1880,849,516,5] +DSCF1104.JPG:[1715,493,684,329,5],[1632,1783,774,426,1] +DSCF1105.JPG:[1090,1016,1312,755,2] +DSCF1106.JPG:[1202,1076,1155,624,2] +DSCF1109.JPG:[1053,878,1178,650,3] +DSCF1110.JPG:[686,743,1159,654,3],[1920,792,1174,643,1] +DSCF1111.JPG:[1890,867,1024,576,6],[671,874,1043,583,2] +DSCF1114.JPG:[1535,1177,994,508,6] +DSCF1116.JPG:[1539,1458,998,523,5] +DSCF1120.JPG:[1236,1274,1324,706,3] +DSCF1122.JPG:[1479,949,1009,542,5] +DSCF1125.JPG:[978,930,654,415,1],[1198,1394,815,482,6],[2406,1252,792,460,2] +DSCF1129.JPG:[1408,1772,792,501,6] +DSCF1130.JPG:[1516,1708,755,471,1] +DSCF1132.JPG:[2751,1005,489,250,1],[2283,1278,893,523,4],[174,1663,1406,740,5] +DSCF1133.JPG:[1352,1192,1140,841,1] +DSCF1135.JPG:[1801,1233,605,359,6] +DSCF1137.JPG:[1879,1136,849,478,2] +DSCF1140.JPG:[1722,594,789,284,6] +DSCF1141.JPG:[1793,665,781,276,2] +DSCF1142.JPG:[914,1200,886,388,2],[2010,1211,878,388,1] diff --git a/data/originalData/runMe.py b/data/originalData/runMe.py new file mode 100644 index 0000000..3b31d3d --- /dev/null +++ b/data/originalData/runMe.py @@ -0,0 +1,122 @@ +# Lior Magram - I.D 316113422, Yuval Noam Feinstein - I.D 206197816 +import numpy as np +import ast +import torch +import os +from my_detectron2 import * + +# def run1(myAnnFileName, buses): +# +# annFileNameGT = os.path.join(os.getcwd(),'annotationsTrain.txt') +# writtenAnnsLines = {} +# annFileEstimations = open(myAnnFileName, 'w+') +# annFileGT = open(annFileNameGT, 'r') +# writtenAnnsLines['Ground_Truth'] = (annFileGT.readlines()) +# +# for k, line_ in enumerate(writtenAnnsLines['Ground_Truth']): +# +# line = line_.replace(' ','') +# imName = line.split(':')[0] +# anns_ = line[line.index(':') + 1:].replace('\n', '') +# anns = ast.literal_eval(anns_) +# if (not isinstance(anns, tuple)): +# anns = [anns] +# corruptAnn = [np.round(np.array(x) + np.random.randint(low = 0, high = 100, size = 5)) for x in anns] +# corruptAnn = [x[:4].tolist() + [anns[i][4]] for i,x in enumerate(corruptAnn)] +# strToWrite = imName + ':' +# if(3 <= k <= 5): +# strToWrite += '\n' +# else: +# for i, ann in enumerate(corruptAnn): +# posStr = [str(x) for x in ann] +# posStr = ','.join(posStr) +# strToWrite += '[' + posStr + ']' +# if (i == int(len(anns)) - 1): +# strToWrite += '\n' +# else: +# strToWrite += ',' +# annFileEstimations.write(strToWrite) +# return + + +def get_img_str(im_outputs, img_name, parse_cfg = None): + ''' + This function gets the outputs of specific image from the preditor, and based on the cfg parses the outputs + by the given format [X1, Y1, W, H, Class]. + :param im_outputs: The networks outputs after applying the image on the predictor. + :param img_name: The name of the given image. + :param parse_cfg: The configuration of the parsing, containing 3 settings: shifiting, XYXY or XYWH and integer + output of the location: + cls_shifted - Our network is predicting color class between 0 to 5. if this setting is True, the + parsing will shift the class to be in the range 1 to 6. + is_XYXY - This setting will determine if the given prediction output from the NN is in + [X1,Y1,X2,Y2] format or in [X1,Y1,W,H] format. if is_XYXY is True it will convert + it to [X1,Y1,W,H] format, else it will keep it in [X1,Y1,W,H] format. + is_int - Will determind if the [X1,Y1,W,H] will be parsed as integer or as floats. If it's + True, it will round the [X1,Y1,W,H] values, else it will parse it as floats (As the + predictor outputs get from the predictor function). + :return: to_prnt - A string which contains the estimated annotation of the given image from our predictor in the + Course's format of [X1, Y1, W, H, Class]. + ''' + to_prnt = '' + + # Loading the parsing configuration if given. + if parse_cfg == None: # Default parsing configuration + cls_shifted=True # Change from class range of 0-5 to a class range of 1-6 + is_XYXY=False # The predictor output format is [X1,Y1,W,H] + is_int=True # Parse to integers representation + else: + cls_shifted, is_XYXY, is_int = parse_cfg # Customize parsing configuration + + num_instances = len(im_outputs["instances"]) + img_name = img_name.upper() + to_prnt = to_prnt + img_name + ':' + boxes = im_outputs["instances"].get("pred_boxes").tensor + classes = im_outputs["instances"].get("pred_classes") + + if is_int: + boxes = torch.round(boxes) + if cls_shifted: + classes = classes + 1 # Updating to range 1 to 6 clases + if not is_XYXY: + boxes[:, 2] = boxes[:, 2] - boxes[:, 0] + boxes[:, 3] = boxes[:, 3] - boxes[:, 1] + + for k in range(num_instances): + obj_str = '' + box = boxes[k] + cl = classes[k] + x1_bus, y1_bus, w_bus, h_bus = box + if is_int: + obj_str = '[%d,%d,%d,%d,%d],' % (x1_bus, y1_bus, w_bus, h_bus, cl) + else: + obj_str = '[%f,%f,%f,%f,%d],' % (x1_bus, y1_bus, w_bus, h_bus, cl) + to_prnt = to_prnt + obj_str + + if num_instances: + to_prnt = to_prnt[:-1] + return to_prnt + +def run(myAnnFileName, bus_dir): + ''' + run - This function gets the myAnnFilename (with path) and buses directory path and calculates the buses + estimation for each image in the buses directory and saves all of the estimation into the an annotation + file (myAnnFileName) with the given format: the name of the image in the beginning of the line, + and then for each bus estimation will be presented as [X1, Y1, W, H, Class]. + The run function uses the buses_predict(img_path) function from our detectron file: + buses_predict(img_path) - The function located at our detectron2 file. This function get an image path + and eval the buses taggings in the image. it returns the network outputs, in + the network predictor format. + :param myAnnFileName: The path for the annotation file of the estimated images. + :param bus_dir: The path for the buses images directory. + :return: None. + ''' + annFileEstimations =open(myAnnFileName, 'w+') + for file in os.listdir(bus_dir): + if file.endswith(".JPG"): + img_path = os.path.join(bus_dir, file) + print(img_path) + pred_outputs = buses_predict(img_path) + pred_parsed = get_img_str(pred_outputs, file, parse_cfg) + annFileEstimations.write(pred_parsed) + return \ No newline at end of file diff --git a/data/train/DSCF1013.JPG b/data/train/DSCF1013.JPG new file mode 100644 index 0000000..15949bb Binary files /dev/null and b/data/train/DSCF1013.JPG differ diff --git a/data/train/DSCF1015.JPG b/data/train/DSCF1015.JPG new file mode 100644 index 0000000..7506f8f Binary files /dev/null and b/data/train/DSCF1015.JPG differ diff --git a/data/train/DSCF1016.JPG b/data/train/DSCF1016.JPG new file mode 100644 index 0000000..8070b77 Binary files /dev/null and b/data/train/DSCF1016.JPG differ diff --git a/data/train/DSCF1017.JPG b/data/train/DSCF1017.JPG new file mode 100644 index 0000000..1a70b6a Binary files /dev/null and b/data/train/DSCF1017.JPG differ diff --git a/data/train/DSCF1021.JPG b/data/train/DSCF1021.JPG new file mode 100644 index 0000000..60022a1 Binary files /dev/null and b/data/train/DSCF1021.JPG differ diff --git a/data/train/DSCF1025.JPG b/data/train/DSCF1025.JPG new file mode 100644 index 0000000..22713ef Binary files /dev/null and b/data/train/DSCF1025.JPG differ diff --git a/data/train/DSCF1032.JPG b/data/train/DSCF1032.JPG new file mode 100644 index 0000000..51e61f8 Binary files /dev/null and b/data/train/DSCF1032.JPG differ diff --git a/data/train/DSCF1037.JPG b/data/train/DSCF1037.JPG new file mode 100644 index 0000000..f460630 Binary files /dev/null and b/data/train/DSCF1037.JPG differ diff --git a/data/train/DSCF1040.JPG b/data/train/DSCF1040.JPG new file mode 100644 index 0000000..cf557e5 Binary files /dev/null and b/data/train/DSCF1040.JPG differ diff --git a/data/train/DSCF1042.JPG b/data/train/DSCF1042.JPG new file mode 100644 index 0000000..413bbaa Binary files /dev/null and b/data/train/DSCF1042.JPG differ diff --git a/data/train/DSCF1048.JPG b/data/train/DSCF1048.JPG new file mode 100644 index 0000000..cd3db1e Binary files /dev/null and b/data/train/DSCF1048.JPG differ diff --git a/data/train/DSCF1049.JPG b/data/train/DSCF1049.JPG new file mode 100644 index 0000000..034cf43 Binary files /dev/null and b/data/train/DSCF1049.JPG differ diff --git a/data/train/DSCF1053.JPG b/data/train/DSCF1053.JPG new file mode 100644 index 0000000..834bec5 Binary files /dev/null and b/data/train/DSCF1053.JPG differ diff --git a/data/train/DSCF1056.JPG b/data/train/DSCF1056.JPG new file mode 100644 index 0000000..139b036 Binary files /dev/null and b/data/train/DSCF1056.JPG differ diff --git a/data/train/DSCF1059.JPG b/data/train/DSCF1059.JPG new file mode 100644 index 0000000..ba7c631 Binary files /dev/null and b/data/train/DSCF1059.JPG differ diff --git a/data/train/DSCF1064.JPG b/data/train/DSCF1064.JPG new file mode 100644 index 0000000..971f7cc Binary files /dev/null and b/data/train/DSCF1064.JPG differ diff --git a/data/train/DSCF1065.JPG b/data/train/DSCF1065.JPG new file mode 100644 index 0000000..83ad467 Binary files /dev/null and b/data/train/DSCF1065.JPG differ diff --git a/data/train/DSCF1070.JPG b/data/train/DSCF1070.JPG new file mode 100644 index 0000000..8667b88 Binary files /dev/null and b/data/train/DSCF1070.JPG differ diff --git a/data/train/DSCF1072.JPG b/data/train/DSCF1072.JPG new file mode 100644 index 0000000..d8fe3e1 Binary files /dev/null and b/data/train/DSCF1072.JPG differ diff --git a/data/train/DSCF1074.JPG b/data/train/DSCF1074.JPG new file mode 100644 index 0000000..c2d98e3 Binary files /dev/null and b/data/train/DSCF1074.JPG differ diff --git a/data/train/DSCF1086.JPG b/data/train/DSCF1086.JPG new file mode 100644 index 0000000..f2adc9d Binary files /dev/null and b/data/train/DSCF1086.JPG differ diff --git a/data/train/DSCF1088.JPG b/data/train/DSCF1088.JPG new file mode 100644 index 0000000..95277e9 Binary files /dev/null and b/data/train/DSCF1088.JPG differ diff --git a/data/train/DSCF1092.JPG b/data/train/DSCF1092.JPG new file mode 100644 index 0000000..111ef52 Binary files /dev/null and b/data/train/DSCF1092.JPG differ diff --git a/data/train/DSCF1094.JPG b/data/train/DSCF1094.JPG new file mode 100644 index 0000000..6dfda85 Binary files /dev/null and b/data/train/DSCF1094.JPG differ diff --git a/data/train/DSCF1099.JPG b/data/train/DSCF1099.JPG new file mode 100644 index 0000000..c706cde Binary files /dev/null and b/data/train/DSCF1099.JPG differ diff --git a/data/train/DSCF1103.JPG b/data/train/DSCF1103.JPG new file mode 100644 index 0000000..b7964b2 Binary files /dev/null and b/data/train/DSCF1103.JPG differ diff --git a/data/train/DSCF1104.JPG b/data/train/DSCF1104.JPG new file mode 100644 index 0000000..ecf7e90 Binary files /dev/null and b/data/train/DSCF1104.JPG differ diff --git a/data/train/DSCF1110.JPG b/data/train/DSCF1110.JPG new file mode 100644 index 0000000..590d1fe Binary files /dev/null and b/data/train/DSCF1110.JPG differ diff --git a/data/train/DSCF1111.JPG b/data/train/DSCF1111.JPG new file mode 100644 index 0000000..4c86e8a Binary files /dev/null and b/data/train/DSCF1111.JPG differ diff --git a/data/train/DSCF1114.JPG b/data/train/DSCF1114.JPG new file mode 100644 index 0000000..94c6d85 Binary files /dev/null and b/data/train/DSCF1114.JPG differ diff --git a/data/train/DSCF1116.JPG b/data/train/DSCF1116.JPG new file mode 100644 index 0000000..84ed271 Binary files /dev/null and b/data/train/DSCF1116.JPG differ diff --git a/data/train/DSCF1120.JPG b/data/train/DSCF1120.JPG new file mode 100644 index 0000000..8ce0252 Binary files /dev/null and b/data/train/DSCF1120.JPG differ diff --git a/data/train/DSCF1125.JPG b/data/train/DSCF1125.JPG new file mode 100644 index 0000000..3c1b907 Binary files /dev/null and b/data/train/DSCF1125.JPG differ diff --git a/data/train/DSCF1130.JPG b/data/train/DSCF1130.JPG new file mode 100644 index 0000000..2cafd00 Binary files /dev/null and b/data/train/DSCF1130.JPG differ diff --git a/data/train/DSCF1132.JPG b/data/train/DSCF1132.JPG new file mode 100644 index 0000000..e694119 Binary files /dev/null and b/data/train/DSCF1132.JPG differ diff --git a/data/train/DSCF1133.JPG b/data/train/DSCF1133.JPG new file mode 100644 index 0000000..afd3238 Binary files /dev/null and b/data/train/DSCF1133.JPG differ diff --git a/data/train/DSCF1135.JPG b/data/train/DSCF1135.JPG new file mode 100644 index 0000000..0896671 Binary files /dev/null and b/data/train/DSCF1135.JPG differ diff --git a/data/train/DSCF1140.JPG b/data/train/DSCF1140.JPG new file mode 100644 index 0000000..971dfb9 Binary files /dev/null and b/data/train/DSCF1140.JPG differ diff --git a/data/train/DSCF1141.JPG b/data/train/DSCF1141.JPG new file mode 100644 index 0000000..feb28c4 Binary files /dev/null and b/data/train/DSCF1141.JPG differ diff --git a/data/train/DSCF1142.JPG b/data/train/DSCF1142.JPG new file mode 100644 index 0000000..cb155fc Binary files /dev/null and b/data/train/DSCF1142.JPG differ diff --git a/data/train/trainDataAnnotations.txt b/data/train/trainDataAnnotations.txt new file mode 100644 index 0000000..3de6c0f --- /dev/null +++ b/data/train/trainDataAnnotations.txt @@ -0,0 +1,40 @@ +DSCF1013.JPG:[1217,1690,489,201,1],[1774,1619,475,224,2],[2313,1566,460,228,3],[1284,1832,497,231,4],[1879,1798,486,228,5],[2429,1742,475,228,6] +DSCF1015.JPG:[641,1342,1181,892,3],[2053,1022,1122,735,6] +DSCF1016.JPG:[1067,1843,1114,613,4],[1954,1278,1021,561,6],[2392,717,964,635,3] +DSCF1017.JPG:[1834,698,789,422,4] +DSCF1021.JPG:[1991,755,923,546,5] +DSCF1025.JPG:[985,1570,1252,710,6] +DSCF1032.JPG:[144,1200,983,467,5],[2339,1125,916,456,6] +DSCF1037.JPG:[1210,1712,1469,643,1] +DSCF1040.JPG:[462,1813,976,546,2],[1445,1791,871,482,1],[2305,1779,785,463,4] +DSCF1042.JPG:[2021,1682,1013,504,5] +DSCF1048.JPG:[443,1230,665,314,4],[1498,1181,665,295,5],[2511,1099,703,310,3] +DSCF1049.JPG:[480,998,789,388,4],[1718,1192,740,396,5],[2758,1364,706,347,3] +DSCF1053.JPG:[925,1536,1006,516,1],[2010,1510,1013,523,6] +DSCF1056.JPG:[469,957,1234,632,2],[1700,953,1219,662,6] +DSCF1059.JPG:[1221,994,1103,706,2] +DSCF1064.JPG:[2399,358,811,519,3],[585,740,927,579,2] +DSCF1065.JPG:[705,1031,811,306,5],[2193,908,766,306,1] +DSCF1070.JPG:[1617,1413,1028,583,2],[1528,990,878,523,6] +DSCF1072.JPG:[746,1211,916,549,3],[1905,1465,968,534,2] +DSCF1074.JPG:[1127,1319,1742,964,2] +DSCF1086.JPG:[716,975,609,332,4],[1471,971,602,336,2],[2175,1005,594,344,1],[2878,990,602,359,3] +DSCF1088.JPG:[1232,440,789,422,5],[1326,1525,654,370,2] +DSCF1092.JPG:[424,1293,867,538,4],[1636,1521,890,516,5],[2481,1028,751,504,3] +DSCF1094.JPG:[1378,1035,991,583,4] +DSCF1099.JPG:[1112,556,1114,564,6] +DSCF1103.JPG:[1475,541,691,359,6],[1168,1880,849,516,5] +DSCF1104.JPG:[1715,493,684,329,5],[1632,1783,774,426,1] +DSCF1110.JPG:[686,743,1159,654,3],[1920,792,1174,643,1] +DSCF1111.JPG:[1890,867,1024,576,6],[671,874,1043,583,2] +DSCF1114.JPG:[1535,1177,994,508,6] +DSCF1116.JPG:[1539,1458,998,523,5] +DSCF1120.JPG:[1236,1274,1324,706,3] +DSCF1125.JPG:[978,930,654,415,1],[1198,1394,815,482,6],[2406,1252,792,460,2] +DSCF1130.JPG:[1516,1708,755,471,1] +DSCF1132.JPG:[2751,1005,489,250,1],[2283,1278,893,523,4],[174,1663,1406,740,5] +DSCF1133.JPG:[1352,1192,1140,841,1] +DSCF1135.JPG:[1801,1233,605,359,6] +DSCF1140.JPG:[1722,594,789,284,6] +DSCF1141.JPG:[1793,665,781,276,2] +DSCF1142.JPG:[914,1200,886,388,2],[2010,1211,878,388,1] diff --git a/data/val/DSCF1023.JPG b/data/val/DSCF1023.JPG new file mode 100644 index 0000000..990512a Binary files /dev/null and b/data/val/DSCF1023.JPG differ diff --git a/data/val/DSCF1029.JPG b/data/val/DSCF1029.JPG new file mode 100644 index 0000000..e54af20 Binary files /dev/null and b/data/val/DSCF1029.JPG differ diff --git a/data/val/DSCF1038.JPG b/data/val/DSCF1038.JPG new file mode 100644 index 0000000..4c73ac7 Binary files /dev/null and b/data/val/DSCF1038.JPG differ diff --git a/data/val/DSCF1044.JPG b/data/val/DSCF1044.JPG new file mode 100644 index 0000000..8cf8153 Binary files /dev/null and b/data/val/DSCF1044.JPG differ diff --git a/data/val/DSCF1050.JPG b/data/val/DSCF1050.JPG new file mode 100644 index 0000000..47b7b9e Binary files /dev/null and b/data/val/DSCF1050.JPG differ diff --git a/data/val/DSCF1061.JPG b/data/val/DSCF1061.JPG new file mode 100644 index 0000000..ea3ef02 Binary files /dev/null and b/data/val/DSCF1061.JPG differ diff --git a/data/val/DSCF1066.JPG b/data/val/DSCF1066.JPG new file mode 100644 index 0000000..9a0617d Binary files /dev/null and b/data/val/DSCF1066.JPG differ diff --git a/data/val/DSCF1068.JPG b/data/val/DSCF1068.JPG new file mode 100644 index 0000000..d66ea7c Binary files /dev/null and b/data/val/DSCF1068.JPG differ diff --git a/data/val/DSCF1077.JPG b/data/val/DSCF1077.JPG new file mode 100644 index 0000000..7c28ee2 Binary files /dev/null and b/data/val/DSCF1077.JPG differ diff --git a/data/val/DSCF1081.JPG b/data/val/DSCF1081.JPG new file mode 100644 index 0000000..f0d44f1 Binary files /dev/null and b/data/val/DSCF1081.JPG differ diff --git a/data/val/DSCF1082.JPG b/data/val/DSCF1082.JPG new file mode 100644 index 0000000..979cdf6 Binary files /dev/null and b/data/val/DSCF1082.JPG differ diff --git a/data/val/DSCF1090.JPG b/data/val/DSCF1090.JPG new file mode 100644 index 0000000..eb5dd85 Binary files /dev/null and b/data/val/DSCF1090.JPG differ diff --git a/data/val/DSCF1097.JPG b/data/val/DSCF1097.JPG new file mode 100644 index 0000000..c95008a Binary files /dev/null and b/data/val/DSCF1097.JPG differ diff --git a/data/val/DSCF1101.JPG b/data/val/DSCF1101.JPG new file mode 100644 index 0000000..5860c93 Binary files /dev/null and b/data/val/DSCF1101.JPG differ diff --git a/data/val/DSCF1105.JPG b/data/val/DSCF1105.JPG new file mode 100644 index 0000000..2648218 Binary files /dev/null and b/data/val/DSCF1105.JPG differ diff --git a/data/val/DSCF1106.JPG b/data/val/DSCF1106.JPG new file mode 100644 index 0000000..bfde090 Binary files /dev/null and b/data/val/DSCF1106.JPG differ diff --git a/data/val/DSCF1109.JPG b/data/val/DSCF1109.JPG new file mode 100644 index 0000000..d818121 Binary files /dev/null and b/data/val/DSCF1109.JPG differ diff --git a/data/val/DSCF1122.JPG b/data/val/DSCF1122.JPG new file mode 100644 index 0000000..b1d6d77 Binary files /dev/null and b/data/val/DSCF1122.JPG differ diff --git a/data/val/DSCF1129.JPG b/data/val/DSCF1129.JPG new file mode 100644 index 0000000..51c4329 Binary files /dev/null and b/data/val/DSCF1129.JPG differ diff --git a/data/val/DSCF1137.JPG b/data/val/DSCF1137.JPG new file mode 100644 index 0000000..570b7a9 Binary files /dev/null and b/data/val/DSCF1137.JPG differ diff --git a/data/val/valDataAnnotations.txt b/data/val/valDataAnnotations.txt new file mode 100644 index 0000000..a910387 --- /dev/null +++ b/data/val/valDataAnnotations.txt @@ -0,0 +1,20 @@ +DSCF1023.JPG:[1909,1166,785,452,2] +DSCF1029.JPG:[129,1648,1271,733,6],[1456,1076,1122,834,2],[2552,826,1058,804,1] +DSCF1038.JPG:[1210,1764,1754,796,2] +DSCF1044.JPG:[1460,1200,946,523,6] +DSCF1050.JPG:[454,766,804,366,5],[1767,807,792,366,3] +DSCF1061.JPG:[488,1648,1361,792,6],[1191,1203,1144,632,2] +DSCF1066.JPG:[1019,1121,718,332,1],[2025,1121,695,321,5] +DSCF1068.JPG:[750,343,1316,501,5],[2459,1533,957,527,1] +DSCF1077.JPG:[308,1282,1110,620,6],[1700,1342,1133,624,1] +DSCF1081.JPG:[1475,1282,714,396,4] +DSCF1082.JPG:[996,579,957,534,5],[2118,601,946,542,4] +DSCF1090.JPG:[1920,784,673,370,1] +DSCF1097.JPG:[1326,642,1155,635,5] +DSCF1101.JPG:[1015,1072,916,504,2] +DSCF1105.JPG:[1090,1016,1312,755,2] +DSCF1106.JPG:[1202,1076,1155,624,2] +DSCF1109.JPG:[1053,878,1178,650,3] +DSCF1122.JPG:[1479,949,1009,542,5] +DSCF1129.JPG:[1408,1772,792,501,6] +DSCF1137.JPG:[1879,1136,849,478,2] diff --git a/data/val2/TEST_ADD_0.JPG b/data/val2/TEST_ADD_0.JPG new file mode 100644 index 0000000..5a8d9e1 Binary files /dev/null and b/data/val2/TEST_ADD_0.JPG differ diff --git a/data/val2/TEST_ADD_1.JPG b/data/val2/TEST_ADD_1.JPG new file mode 100644 index 0000000..f585f48 Binary files /dev/null and b/data/val2/TEST_ADD_1.JPG differ diff --git a/data/val2/TEST_ADD_10.JPG b/data/val2/TEST_ADD_10.JPG new file mode 100644 index 0000000..e6ee9d0 Binary files /dev/null and b/data/val2/TEST_ADD_10.JPG differ diff --git a/data/val2/TEST_ADD_11.JPG b/data/val2/TEST_ADD_11.JPG new file mode 100644 index 0000000..5dcdc43 Binary files /dev/null and b/data/val2/TEST_ADD_11.JPG differ diff --git a/data/val2/TEST_ADD_12.JPG b/data/val2/TEST_ADD_12.JPG new file mode 100644 index 0000000..a9c146a Binary files /dev/null and b/data/val2/TEST_ADD_12.JPG differ diff --git a/data/val2/TEST_ADD_13.JPG b/data/val2/TEST_ADD_13.JPG new file mode 100644 index 0000000..f9179a0 Binary files /dev/null and b/data/val2/TEST_ADD_13.JPG differ diff --git a/data/val2/TEST_ADD_14.JPG b/data/val2/TEST_ADD_14.JPG new file mode 100644 index 0000000..1c815e9 Binary files /dev/null and b/data/val2/TEST_ADD_14.JPG differ diff --git a/data/val2/TEST_ADD_15.JPG b/data/val2/TEST_ADD_15.JPG new file mode 100644 index 0000000..ef2aa85 Binary files /dev/null and b/data/val2/TEST_ADD_15.JPG differ diff --git a/data/val2/TEST_ADD_16.JPG b/data/val2/TEST_ADD_16.JPG new file mode 100644 index 0000000..28ca79e Binary files /dev/null and b/data/val2/TEST_ADD_16.JPG differ diff --git a/data/val2/TEST_ADD_17.JPG b/data/val2/TEST_ADD_17.JPG new file mode 100644 index 0000000..bdabdb1 Binary files /dev/null and b/data/val2/TEST_ADD_17.JPG differ diff --git a/data/val2/TEST_ADD_18.JPG b/data/val2/TEST_ADD_18.JPG new file mode 100644 index 0000000..e124d34 Binary files /dev/null and b/data/val2/TEST_ADD_18.JPG differ diff --git a/data/val2/TEST_ADD_19.JPG b/data/val2/TEST_ADD_19.JPG new file mode 100644 index 0000000..b642eea Binary files /dev/null and b/data/val2/TEST_ADD_19.JPG differ diff --git a/data/val2/TEST_ADD_2.JPG b/data/val2/TEST_ADD_2.JPG new file mode 100644 index 0000000..dbf9e52 Binary files /dev/null and b/data/val2/TEST_ADD_2.JPG differ diff --git a/data/val2/TEST_ADD_20.JPG b/data/val2/TEST_ADD_20.JPG new file mode 100644 index 0000000..0f32fce Binary files /dev/null and b/data/val2/TEST_ADD_20.JPG differ diff --git a/data/val2/TEST_ADD_21.JPG b/data/val2/TEST_ADD_21.JPG new file mode 100644 index 0000000..4374043 Binary files /dev/null and b/data/val2/TEST_ADD_21.JPG differ diff --git a/data/val2/TEST_ADD_22.JPG b/data/val2/TEST_ADD_22.JPG new file mode 100644 index 0000000..607389d Binary files /dev/null and b/data/val2/TEST_ADD_22.JPG differ diff --git a/data/val2/TEST_ADD_23.JPG b/data/val2/TEST_ADD_23.JPG new file mode 100644 index 0000000..d5b20ac Binary files /dev/null and b/data/val2/TEST_ADD_23.JPG differ diff --git a/data/val2/TEST_ADD_24.JPG b/data/val2/TEST_ADD_24.JPG new file mode 100644 index 0000000..78562c1 Binary files /dev/null and b/data/val2/TEST_ADD_24.JPG differ diff --git a/data/val2/TEST_ADD_25.JPG b/data/val2/TEST_ADD_25.JPG new file mode 100644 index 0000000..7b7693a Binary files /dev/null and b/data/val2/TEST_ADD_25.JPG differ diff --git a/data/val2/TEST_ADD_26.JPG b/data/val2/TEST_ADD_26.JPG new file mode 100644 index 0000000..5674304 Binary files /dev/null and b/data/val2/TEST_ADD_26.JPG differ diff --git a/data/val2/TEST_ADD_27.JPG b/data/val2/TEST_ADD_27.JPG new file mode 100644 index 0000000..72194d5 Binary files /dev/null and b/data/val2/TEST_ADD_27.JPG differ diff --git a/data/val2/TEST_ADD_28.JPG b/data/val2/TEST_ADD_28.JPG new file mode 100644 index 0000000..6aa369d Binary files /dev/null and b/data/val2/TEST_ADD_28.JPG differ diff --git a/data/val2/TEST_ADD_29.JPG b/data/val2/TEST_ADD_29.JPG new file mode 100644 index 0000000..7f70e13 Binary files /dev/null and b/data/val2/TEST_ADD_29.JPG differ diff --git a/data/val2/TEST_ADD_3.JPG b/data/val2/TEST_ADD_3.JPG new file mode 100644 index 0000000..d8a073f Binary files /dev/null and b/data/val2/TEST_ADD_3.JPG differ diff --git a/data/val2/TEST_ADD_30.JPG b/data/val2/TEST_ADD_30.JPG new file mode 100644 index 0000000..d2501c6 Binary files /dev/null and b/data/val2/TEST_ADD_30.JPG differ diff --git a/data/val2/TEST_ADD_31.JPG b/data/val2/TEST_ADD_31.JPG new file mode 100644 index 0000000..8c979c2 Binary files /dev/null and b/data/val2/TEST_ADD_31.JPG differ diff --git a/data/val2/TEST_ADD_32.JPG b/data/val2/TEST_ADD_32.JPG new file mode 100644 index 0000000..ea0e167 Binary files /dev/null and b/data/val2/TEST_ADD_32.JPG differ diff --git a/data/val2/TEST_ADD_33.JPG b/data/val2/TEST_ADD_33.JPG new file mode 100644 index 0000000..735f67e Binary files /dev/null and b/data/val2/TEST_ADD_33.JPG differ diff --git a/data/val2/TEST_ADD_34.JPG b/data/val2/TEST_ADD_34.JPG new file mode 100644 index 0000000..102b5fd Binary files /dev/null and b/data/val2/TEST_ADD_34.JPG differ diff --git a/data/val2/TEST_ADD_35.JPG b/data/val2/TEST_ADD_35.JPG new file mode 100644 index 0000000..fb50c34 Binary files /dev/null and b/data/val2/TEST_ADD_35.JPG differ diff --git a/data/val2/TEST_ADD_36.JPG b/data/val2/TEST_ADD_36.JPG new file mode 100644 index 0000000..88fe818 Binary files /dev/null and b/data/val2/TEST_ADD_36.JPG differ diff --git a/data/val2/TEST_ADD_37.JPG b/data/val2/TEST_ADD_37.JPG new file mode 100644 index 0000000..0cfcb86 Binary files /dev/null and b/data/val2/TEST_ADD_37.JPG differ diff --git a/data/val2/TEST_ADD_38.JPG b/data/val2/TEST_ADD_38.JPG new file mode 100644 index 0000000..2054e44 Binary files /dev/null and b/data/val2/TEST_ADD_38.JPG differ diff --git a/data/val2/TEST_ADD_39.JPG b/data/val2/TEST_ADD_39.JPG new file mode 100644 index 0000000..57cf8db Binary files /dev/null and b/data/val2/TEST_ADD_39.JPG differ diff --git a/data/val2/TEST_ADD_4.JPG b/data/val2/TEST_ADD_4.JPG new file mode 100644 index 0000000..fac7444 Binary files /dev/null and b/data/val2/TEST_ADD_4.JPG differ diff --git a/data/val2/TEST_ADD_40.JPG b/data/val2/TEST_ADD_40.JPG new file mode 100644 index 0000000..0ee580c Binary files /dev/null and b/data/val2/TEST_ADD_40.JPG differ diff --git a/data/val2/TEST_ADD_41.JPG b/data/val2/TEST_ADD_41.JPG new file mode 100644 index 0000000..7e28903 Binary files /dev/null and b/data/val2/TEST_ADD_41.JPG differ diff --git a/data/val2/TEST_ADD_42.JPG b/data/val2/TEST_ADD_42.JPG new file mode 100644 index 0000000..bb2fbd0 Binary files /dev/null and b/data/val2/TEST_ADD_42.JPG differ diff --git a/data/val2/TEST_ADD_43.JPG b/data/val2/TEST_ADD_43.JPG new file mode 100644 index 0000000..5dbf10e Binary files /dev/null and b/data/val2/TEST_ADD_43.JPG differ diff --git a/data/val2/TEST_ADD_44.JPG b/data/val2/TEST_ADD_44.JPG new file mode 100644 index 0000000..e81f527 Binary files /dev/null and b/data/val2/TEST_ADD_44.JPG differ diff --git a/data/val2/TEST_ADD_45.JPG b/data/val2/TEST_ADD_45.JPG new file mode 100644 index 0000000..2631c09 Binary files /dev/null and b/data/val2/TEST_ADD_45.JPG differ diff --git a/data/val2/TEST_ADD_46.JPG b/data/val2/TEST_ADD_46.JPG new file mode 100644 index 0000000..66f0a51 Binary files /dev/null and b/data/val2/TEST_ADD_46.JPG differ diff --git a/data/val2/TEST_ADD_47.JPG b/data/val2/TEST_ADD_47.JPG new file mode 100644 index 0000000..92587e9 Binary files /dev/null and b/data/val2/TEST_ADD_47.JPG differ diff --git a/data/val2/TEST_ADD_48.JPG b/data/val2/TEST_ADD_48.JPG new file mode 100644 index 0000000..fd3fc97 Binary files /dev/null and b/data/val2/TEST_ADD_48.JPG differ diff --git a/data/val2/TEST_ADD_49.JPG b/data/val2/TEST_ADD_49.JPG new file mode 100644 index 0000000..7202fd8 Binary files /dev/null and b/data/val2/TEST_ADD_49.JPG differ diff --git a/data/val2/TEST_ADD_5.JPG b/data/val2/TEST_ADD_5.JPG new file mode 100644 index 0000000..7558460 Binary files /dev/null and b/data/val2/TEST_ADD_5.JPG differ diff --git a/data/val2/TEST_ADD_50.JPG b/data/val2/TEST_ADD_50.JPG new file mode 100644 index 0000000..d3ee572 Binary files /dev/null and b/data/val2/TEST_ADD_50.JPG differ diff --git a/data/val2/TEST_ADD_51.JPG b/data/val2/TEST_ADD_51.JPG new file mode 100644 index 0000000..1cc18b2 Binary files /dev/null and b/data/val2/TEST_ADD_51.JPG differ diff --git a/data/val2/TEST_ADD_52.JPG b/data/val2/TEST_ADD_52.JPG new file mode 100644 index 0000000..ab672f0 Binary files /dev/null and b/data/val2/TEST_ADD_52.JPG differ diff --git a/data/val2/TEST_ADD_53.JPG b/data/val2/TEST_ADD_53.JPG new file mode 100644 index 0000000..947f183 Binary files /dev/null and b/data/val2/TEST_ADD_53.JPG differ diff --git a/data/val2/TEST_ADD_54.JPG b/data/val2/TEST_ADD_54.JPG new file mode 100644 index 0000000..2b87220 Binary files /dev/null and b/data/val2/TEST_ADD_54.JPG differ diff --git a/data/val2/TEST_ADD_55.JPG b/data/val2/TEST_ADD_55.JPG new file mode 100644 index 0000000..72f26e4 Binary files /dev/null and b/data/val2/TEST_ADD_55.JPG differ diff --git a/data/val2/TEST_ADD_56.JPG b/data/val2/TEST_ADD_56.JPG new file mode 100644 index 0000000..4a9d256 Binary files /dev/null and b/data/val2/TEST_ADD_56.JPG differ diff --git a/data/val2/TEST_ADD_57.JPG b/data/val2/TEST_ADD_57.JPG new file mode 100644 index 0000000..44afae8 Binary files /dev/null and b/data/val2/TEST_ADD_57.JPG differ diff --git a/data/val2/TEST_ADD_58.JPG b/data/val2/TEST_ADD_58.JPG new file mode 100644 index 0000000..4608e9c Binary files /dev/null and b/data/val2/TEST_ADD_58.JPG differ diff --git a/data/val2/TEST_ADD_59.JPG b/data/val2/TEST_ADD_59.JPG new file mode 100644 index 0000000..a593388 Binary files /dev/null and b/data/val2/TEST_ADD_59.JPG differ diff --git a/data/val2/TEST_ADD_6.JPG b/data/val2/TEST_ADD_6.JPG new file mode 100644 index 0000000..cce9545 Binary files /dev/null and b/data/val2/TEST_ADD_6.JPG differ diff --git a/data/val2/TEST_ADD_60.JPG b/data/val2/TEST_ADD_60.JPG new file mode 100644 index 0000000..83752e0 Binary files /dev/null and b/data/val2/TEST_ADD_60.JPG differ diff --git a/data/val2/TEST_ADD_7.JPG b/data/val2/TEST_ADD_7.JPG new file mode 100644 index 0000000..81ee2e8 Binary files /dev/null and b/data/val2/TEST_ADD_7.JPG differ diff --git a/data/val2/TEST_ADD_8.JPG b/data/val2/TEST_ADD_8.JPG new file mode 100644 index 0000000..781b0fc Binary files /dev/null and b/data/val2/TEST_ADD_8.JPG differ diff --git a/data/val2/TEST_ADD_9.JPG b/data/val2/TEST_ADD_9.JPG new file mode 100644 index 0000000..a30463f Binary files /dev/null and b/data/val2/TEST_ADD_9.JPG differ diff --git a/data/val2/val2DataAnnotations.txt b/data/val2/val2DataAnnotations.txt new file mode 100644 index 0000000..addcdfc --- /dev/null +++ b/data/val2/val2DataAnnotations.txt @@ -0,0 +1,61 @@ +TEST_ADD_0.JPG:[2527,175,224,594,5],[444,1672,553,1004,1],[2404,834,895,414,5] +TEST_ADD_1.JPG:[497,1954,882,565,3],[2637,767,916,542,6],[1420,1126,795,1242,2],[2831,1916,649,382,4],[2228,1136,778,383,4],[2963,94,253,578,2] +TEST_ADD_2.JPG:[839,1302,1290,711,1],[1372,2233,437,165,5],[89,939,501,897,2],[1255,196,492,1083,2],[1734,207,843,451,5],[1739,491,726,1318,1] +TEST_ADD_3.JPG:[625,1169,1199,661,2],[2666,1151,353,800,3] +TEST_ADD_4.JPG:[1000,1646,462,912,6] +TEST_ADD_5.JPG:[2530,507,845,541,3] +TEST_ADD_6.JPG:[1069,716,757,1393,6],[2600,1773,783,407,6],[416,2204,294,532,6],[1171,2332,598,311,6],[2353,2166,1097,563,1] +TEST_ADD_7.JPG:[392,303,570,1145,5],[1047,1078,411,827,5] +TEST_ADD_8.JPG:[1342,252,929,457,4],[2576,2343,494,274,4],[2931,999,715,325,5],[3096,167,544,924,4],[1492,708,575,899,3],[2189,714,606,1054,2] +TEST_ADD_9.JPG:[2115,1656,299,543,2],[3264,1779,247,527,5],[1228,671,249,120,6] +TEST_ADD_10.JPG:[976,1291,350,639,1],[1167,1113,1426,809,6],[1898,937,598,342,4] +TEST_ADD_11.JPG:[2020,1447,601,1022,4],[1535,982,235,531,5],[670,1379,345,627,1],[998,633,340,618,6],[1832,2071,231,479,5] +TEST_ADD_12.JPG:[3128,39,371,674,2] +TEST_ADD_13.JPG:[2037,681,973,1288,3],[518,207,377,590,3],[1511,754,297,597,6] +TEST_ADD_14.JPG:[2106,1963,1384,527,5],[1342,338,673,1204,2] +TEST_ADD_15.JPG:[2484,1482,908,447,3],[85,100,359,636,3],[2489,971,490,241,3],[421,628,1159,875,3],[1059,609,919,1597,2] +TEST_ADD_16.JPG:[706,333,1100,564,1],[197,1180,698,396,2],[1146,1643,215,371,1],[1480,1250,562,1088,6] +TEST_ADD_17.JPG:[3254,1881,304,619,3],[13,1944,665,341,1],[1668,542,705,406,2],[1062,2134,284,134,2],[1210,1407,1186,896,3],[730,818,511,864,5] +TEST_ADD_18.JPG:[1755,1752,379,203,5],[2618,212,521,1097,5],[781,670,354,193,4],[2373,2289,933,431,1],[381,803,805,1462,1],[598,2255,631,350,4] +TEST_ADD_19.JPG:[1024,1007,860,1131,1],[1817,1929,349,625,2],[645,1001,214,535,1],[1641,1163,1446,1075,2],[2462,763,543,316,2] +TEST_ADD_20.JPG:[2974,1038,259,476,4],[2880,1950,436,782,5],[1094,662,623,928,3],[1013,1337,223,506,3],[858,1694,1723,953,2] +TEST_ADD_21.JPG:[1961,1796,410,793,6],[2537,1839,588,333,2] +TEST_ADD_22.JPG:[898,1145,459,822,2],[1029,47,222,397,2],[2478,1475,525,906,5],[122,954,760,1675,2] +TEST_ADD_23.JPG:[2712,1065,223,403,4],[1474,490,344,195,2],[432,26,398,177,5],[1515,1744,479,644,2] +TEST_ADD_24.JPG:[2851,2019,636,344,2],[680,1662,714,399,2],[1990,2235,1042,495,5],[15,2052,1041,646,4],[3163,1689,154,301,1] +TEST_ADD_25.JPG:[631,117,144,300,6],[972,874,987,560,2],[2231,2127,385,230,3],[2101,1436,708,348,3],[605,1624,864,643,2] +TEST_ADD_26.JPG:[360,161,375,206,1],[2484,1047,430,775,4],[956,1122,350,704,5],[414,330,1569,826,5],[1228,1309,956,612,3],[528,1753,958,549,4] +TEST_ADD_27.JPG:[284,1222,728,431,5],[476,744,273,581,5],[968,1094,1457,767,5] +TEST_ADD_28.JPG:[1166,871,354,611,1] +TEST_ADD_29.JPG:[93,334,254,466,4],[1819,524,1043,534,2],[1329,708,790,459,2],[1188,1241,361,647,2],[635,1941,988,647,6] +TEST_ADD_30.JPG:[317,404,940,411,2],[997,677,917,1576,6],[1562,204,400,724,2] +TEST_ADD_31.JPG:[2019,1138,502,912,1],[2274,1534,993,581,4],[1717,21,1217,463,5] +TEST_ADD_32.JPG:[37,2156,965,531,2] +TEST_ADD_33.JPG:[640,1698,343,511,3] +TEST_ADD_34.JPG:[799,1521,120,258,4],[1110,1501,474,814,6],[316,548,991,508,2] +TEST_ADD_35.JPG:[2815,1730,729,412,3],[399,1470,334,679,4],[2660,2132,601,360,3],[2277,1500,366,162,5] +TEST_ADD_36.JPG:[922,1422,1151,634,1] +TEST_ADD_37.JPG:[2774,783,847,374,1],[815,1294,637,254,1],[1204,174,728,964,3],[630,1010,463,842,1] +TEST_ADD_38.JPG:[2060,1398,619,334,2],[2797,1768,546,262,6],[57,1632,629,299,5],[728,612,1250,689,2],[1348,295,254,475,5] +TEST_ADD_39.JPG:[250,907,325,151,4],[977,366,301,511,4],[2643,1237,397,621,2],[1660,865,985,539,1] +TEST_ADD_40.JPG:[103,462,561,852,3] +TEST_ADD_41.JPG:[1172,898,853,443,6] +TEST_ADD_42.JPG:[3265,383,360,638,3],[2034,1871,1008,557,2],[935,644,266,604,3],[2214,1298,344,643,5],[1674,552,365,913,1],[1486,931,489,844,5] +TEST_ADD_43.JPG:[1473,863,554,245,3],[130,1292,591,1003,4],[3209,74,313,651,5],[2596,200,525,298,2] +TEST_ADD_44.JPG:[2362,694,250,566,1] +TEST_ADD_45.JPG:[1724,682,271,127,5],[907,65,277,608,5],[1980,439,1222,923,3],[1574,1107,575,379,3],[2858,1271,565,1117,6],[81,1403,335,710,4] +TEST_ADD_46.JPG:[1471,2207,929,514,2],[2069,1465,263,698,5],[1836,519,590,1030,4],[1335,929,545,947,2] +TEST_ADD_47.JPG:[1890,301,1396,894,2],[3024,1482,275,559,3],[240,221,664,874,1],[1680,1311,296,530,2],[834,1105,721,397,1] +TEST_ADD_48.JPG:[304,294,831,469,3],[412,1766,738,549,2],[453,1046,509,854,6],[1152,854,513,237,5],[681,2141,768,453,4],[1797,1441,700,1240,3] +TEST_ADD_49.JPG:[2275,1421,514,897,4],[1168,2298,518,324,2] +TEST_ADD_50.JPG:[818,602,493,896,2],[2051,382,1256,625,5],[2866,1020,483,843,4] +TEST_ADD_51.JPG:[547,1988,328,588,2],[1770,1891,730,435,6],[2233,1824,868,477,2],[1909,801,446,221,3] +TEST_ADD_52.JPG:[1934,1875,496,271,4],[1947,1149,363,785,3] +TEST_ADD_53.JPG:[3170,1043,464,858,2],[922,1420,475,263,1],[6,1665,506,790,2],[2694,1610,832,458,1],[2312,266,440,672,6] +TEST_ADD_54.JPG:[2949,1240,603,278,5] +TEST_ADD_55.JPG:[1967,131,417,686,5],[732,153,948,555,4],[319,1427,1624,937,6],[1031,788,376,177,2],[1243,600,822,482,4] +TEST_ADD_56.JPG:[1296,548,215,537,1],[1668,1904,645,386,3],[1827,1216,395,718,1],[2335,902,1305,705,2],[805,857,353,776,5],[1431,189,858,565,3] +TEST_ADD_57.JPG:[493,597,1118,831,2],[1270,1745,568,862,3] +TEST_ADD_58.JPG:[2466,12,805,1222,3] +TEST_ADD_59.JPG:[3229,255,288,587,3],[2079,1037,949,560,4],[700,2156,1190,540,2],[387,1074,810,1436,3] +TEST_ADD_60.JPG:[304,1079,649,286,3] \ No newline at end of file diff --git a/detectron2/config/compat.py b/detectron2/config/compat.py index 41fe3a0..27478ba 100644 --- a/detectron2/config/compat.py +++ b/detectron2/config/compat.py @@ -148,7 +148,8 @@ class _RenameConverter: A converter that handles simple rename. """ - RENAME: List[Tuple[str, str]] = [] # list of tuples of (old name, new name) + # RENAME: List[Tuple[str, str]] = [] # list of tuples of (old name, new name) + RENAME = [] # @classmethod def upgrade(cls, cfg: CN) -> None: diff --git a/detectron2/model_zoo/model_zoo.py b/detectron2/model_zoo/model_zoo.py index 45cf70f..7fa2d3c 100644 --- a/detectron2/model_zoo/model_zoo.py +++ b/detectron2/model_zoo/model_zoo.py @@ -74,8 +74,9 @@ class ModelZooUrls(object): @classmethod def get(cls, config_path): + name = config_path.replace(".yaml", "") if config_path in cls.CONFIG_PATH_TO_URL_SUFFIX: - name = config_path.replace(".yaml", "") + # name = config_path.replace(".yaml", "") return cls.S3_PREFIX + name + "/" + cls.CONFIG_PATH_TO_URL_SUFFIX[config_path] raise RuntimeError("{} not available in Model Zoo!".format(name)) @@ -112,3 +113,23 @@ def get(config_path, trained: bool = False): model = build_model(cfg) DetectionCheckpointer(model).load(cfg.MODEL.WEIGHTS) return model + + +# Addition +def get_config_file(config_path): + """ + Returns path to a builtin config file. + + Args: + config_path (str): config file name relative to detectron2's "configs/" + directory, e.g., "COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml" + + Returns: + str: the real path to the config file. + """ + cfg_file = pkg_resources.resource_filename( + "detectron2.model_zoo", os.path.join("configs", config_path) + ) + if not os.path.exists(cfg_file): + raise RuntimeError("{} not available in Model Zoo!".format(config_path)) + return cfg_file \ No newline at end of file diff --git a/detectron2/modeling/meta_arch/rcnn.py b/detectron2/modeling/meta_arch/rcnn.py index 5fefe64..ff20011 100644 --- a/detectron2/modeling/meta_arch/rcnn.py +++ b/detectron2/modeling/meta_arch/rcnn.py @@ -27,7 +27,8 @@ class GeneralizedRCNN(nn.Module): def __init__(self, cfg): super().__init__() - self.device = torch.device(cfg.MODEL.DEVICE) + self.device = torch.device(cfg.MODEL.DEVICE) if torch.cuda.is_available() else 'cpu' + # self.device = torch.device('cpu') self.backbone = build_backbone(cfg) self.proposal_generator = build_proposal_generator(cfg, self.backbone.output_shape()) self.roi_heads = build_roi_heads(cfg, self.backbone.output_shape()) diff --git a/detectron2_tutorial.py b/detectron2_tutorial.py new file mode 100644 index 0000000..9b24cfd --- /dev/null +++ b/detectron2_tutorial.py @@ -0,0 +1,258 @@ +# You may need to restart your runtime prior to this, to let your installation take effect +# Some basic setup +# Setup detectron2 logger +import detectron2 +from detectron2.utils.logger import setup_logger +from detectron2.engine import DefaultTrainer +from detectron2.config import get_cfg +from detectron2.data import DatasetCatalog, MetadataCatalog +import torch, torchvision + +# import some common libraries +import numpy as np +import cv2 +import random +import matplotlib.pyplot as plt + +# import some common detectron2 utilities +from detectron2 import model_zoo +from detectron2.engine import DefaultPredictor +from detectron2.config import get_cfg +from detectron2.utils.visualizer import Visualizer +from detectron2.data import MetadataCatalog +from detectron2.model_zoo.model_zoo import get_config_file +from detectron2.utils.visualizer import ColorMode +setup_logger() + +import os +import json +from detectron2.structures import BoxMode +import itertools +import re + + +# IMAGE_HEIGHT = 2736 +# IMAGE_WIDTH = 3648 + +def find_line_index(lines, name): + ''' + This function finds the index of last line that contains the given name. if + there is not one - the function will return -1. + Inputs: + lines - An arrays of strings + name - name to be search + output: + k0 - An integer which indicates in which line the last name appears. if + it doesn't appear at all it will return -1. + ''' + k0 = -1 + for k in range(len(lines)): + line = lines[k] + if name in line: + k0 = k + return k0 + + +def unwrap_tags(line, is_xyxy): + ''' + This function gets the string of a line in the tags txt file, and + returns the line bounding-box 2 coordinates (x1,y1,x2,y2) and the class + of each bounding box tag. if it invalid line it returns Null. + Input: + line - string, which contain the bounding boxes. + Ouput: + boxes - Numpy-array Nx4 which contain for N bounding boxes taggings + in the picture the 2-coordinates for the bounding box + (x1, y1, x2, y2) as floats. + tag_class - returns Nx1 array which contains the class of each box. + ''' + # spec_line = re.sub(img_name+img_suffix+':','', bbox_lines[line]).split()[-1] + if line.find(':') == -1: + print('ERROR') + return + line = line[line.find(':') + 1:-1].split()[-1] + # print(line) + pre_boxes = line.split('],[') + boxes = np.zeros((len(pre_boxes), 5)) + for k in range(len(pre_boxes)): + pre_boxes[k] = re.sub('[[]', '', pre_boxes[k]) + pre_boxes[k] = re.sub('[]]', '', pre_boxes[k]) + tmp = np.array(pre_boxes[k].split(',')).astype(int) + boxes[k] = tmp + + if is_xyxy: + boxes[:, 2] = boxes[:, 0] + boxes[:, 2] + boxes[:, 3] = boxes[:, 1] + boxes[:, 3] + + tag_class = boxes[:, 4].astype(int) + return boxes[:, :-1], tag_class + +def get_balloon_dicts(img_dir): + print('balloon') + json_file = os.path.join(img_dir, "via_region_data.json") + with open(json_file) as f: + imgs_anns = json.load(f) + + dataset_dicts = [] + for idx, v in enumerate(imgs_anns.values()): + record = {} + + filename = os.path.join(img_dir, v["filename"]) + height, width = cv2.imread(filename).shape[:2] + + record["file_name"] = filename + record["image_id"] = idx + record["height"] = height + record["width"] = width + + annos = v["regions"] + objs = [] + for _, anno in annos.items(): + assert not anno["region_attributes"] + anno = anno["shape_attributes"] + px = anno["all_points_x"] + py = anno["all_points_y"] + poly = [(x + 0.5, y + 0.5) for x, y in zip(px, py)] + poly = list(itertools.chain.from_iterable(poly)) + + obj = { + "bbox": [np.min(px), np.min(py), np.max(px), np.max(py)], + "bbox_mode": BoxMode.XYXY_ABS, + "segmentation": [poly], + "category_id": 0, + "iscrowd": 0 + } + objs.append(obj) + record["annotations"] = objs + dataset_dicts.append(record) + return dataset_dicts + +def get_bus_dicts(img_dir): + + annotations_path = os.path.join(img_dir, 'originalAnnotationsTrain.txt') + + # Load tagging files + f_original = open(annotations_path, 'r') + + original_lines = f_original.readlines() + + images_list = [] + image_names = [] + dataset_dicts = [] + + for line_idx, line in enumerate(original_lines): + annotations = [] + + image_filename = line.split(':')[0] + image_id = line_idx + 1 + + image_annotations_list = [] + + tags, tag_class = unwrap_tags(original_lines[line_idx], is_xyxy=False) + + record = {} + + full_filename = os.path.join(img_dir, image_filename) + image_height, image_width = cv2.imread(full_filename).shape[:2] + + record["file_name"] = full_filename + record["image_id"] = image_id + record["height"] = image_height + record["width"] = image_width + + objs = [] + for j in range(len(tag_class)): + + obj = { + "bbox": tags[j], + "bbox_mode": BoxMode.XYWH_ABS, + # "segmentation": [], + "category_id": int(tag_class[j]-1), + "iscrowd": 0 + } + objs.append(obj) + record["annotations"] = objs + dataset_dicts.append(record) + return dataset_dicts + +def verification(metadata): + + dataset_dicts = get_bus_dicts(os.path.join("..", "data", "originalData", "pictures")) + + l = 0 + for d in random.sample(dataset_dicts, 10): + img = cv2.imread(d["file_name"]) + visualizer = Visualizer(img[:, :, ::-1], metadata=metadata, scale=0.5) + vis = visualizer.draw_dataset_dict(d) + cv2.imwrite('a' + str(l) + '.jpg', (vis.get_image()[:, :, ::-1])) + l+=1 + + + +def train(): + cfg = get_cfg() + cfg.merge_from_file(get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")) + cfg.DATASETS.TRAIN = ("bus_train",) + cfg.DATASETS.TEST = ("bus_train",) #TODO change back + cfg.DATALOADER.NUM_WORKERS = 1 + + + cfg.MODEL.WEIGHTS = "model_final_280758.pkl" # Let training initialize from model zoo + # cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/fast_rcnn_R_50_FPN_1x/137257794/model_final_b275ba.pkl" # Let training initialize from model zoo + # cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/fast_rcnn_R_50_FPN_1x/137849600/model_final_f10217.pklmodel_final_b275ba.pkl" # Let training initialize from model zoo + + cfg.MODEL.LOAD_PROPOSALS = False + # cfg.DATASETS.PROPOSAL_FILES_TRAIN = "coco_2017_train_box_proposals_21bc3a.pkl" + + cfg.SOLVER.IMS_PER_BATCH = 1 + cfg.SOLVER.BASE_LR = 0.1 + cfg.SOLVER.MAX_ITER = 1 # 300 iterations seems good enough, but you can certainly train longer + cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 512 # faster, and good enough for this toy dataset + cfg.MODEL.ROI_HEADS.NUM_CLASSES = 6 + + os.makedirs(cfg.OUTPUT_DIR, exist_ok=True) + trainer = DefaultTrainer(cfg) + trainer.resume_or_load(resume=False) + trainer.train() + +def eval(metadata): + cfg = get_cfg() + cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final.pth") + cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.01 # TODO change back to 0.7 set the testing threshold for this model + cfg.DATASETS.TEST = ("bus_train",) + predictor = DefaultPredictor(cfg) + + dataset_dicts = get_bus_dicts(os.path.join("..", "data", "toyData", "pictures")) + k=0 + for d in random.sample(dataset_dicts, 3): + im = cv2.imread(d["file_name"]) + outputs = predictor(im) + v = Visualizer(im[:, :, ::-1], + metadata=metadata, + scale=0.8, + ) + v = v.draw_instance_predictions(outputs["instances"].to("cpu")) + # cv2_imshow(v.get_image()[:, :, ::-1]) + cv2.imwrite('c' + str(k) + '.jpg', (v.get_image()[:, :, ::-1])) + k+=1 + + +def main(): + + for d in ["train"]: + DatasetCatalog.register("bus_" + d, lambda d=d: get_bus_dicts(os.path.join("..", "data", "toyData", "pictures"))) + MetadataCatalog.get("bus_" + d).set(thing_classes=['0', '1', '2', '3', '4', '5']) + buses_metadata = MetadataCatalog.get("bus_train") + + verification(buses_metadata, 'bus') + + print('started training') + # train() + print('finished training') + print('starting evaluation') + # eval(buses_metadata) + print('finished evaluation') + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/main_output/empty.txt b/main_output/empty.txt new file mode 100644 index 0000000..cfcf412 --- /dev/null +++ b/main_output/empty.txt @@ -0,0 +1 @@ +trial \ No newline at end of file diff --git a/my_detectron_main.py b/my_detectron_main.py new file mode 100644 index 0000000..15e0b80 --- /dev/null +++ b/my_detectron_main.py @@ -0,0 +1,96 @@ +from my_utils import * +from net_methods import * + +def get_bus_dicts(img_dir, relevant_lines): + + dataset_dicts = [] + + for line_idx, line in enumerate(relevant_lines): + + image_filename = line.split(':')[0] + image_id = line_idx + 1 + + tags, tag_class = unwrap_tags(relevant_lines[line_idx], is_xyxy=False) + + record = {} + + full_filename = os.path.join(img_dir, image_filename) + image_height, image_width = cv2.imread(full_filename).shape[:2] + + record["file_name"] = full_filename + record["image_id"] = image_id + record["height"] = image_height + record["width"] = image_width + + objs = [] + for j in range(len(tag_class)): + + obj = { + "bbox": tags[j], + "bbox_mode": BoxMode.XYWH_ABS, + "category_id": int(tag_class[j] - 1), + "iscrowd": 0 + } + objs.append(obj) + record["annotations"] = objs + dataset_dicts.append(record) + return dataset_dicts + +def verification(metadata, pictures_dir, annotation_lines): + + dataset_dicts = get_bus_dicts(pictures_dir, annotation_lines) + + l = 0 + for d in random.sample(dataset_dicts, 10): + img = cv2.imread(d["file_name"]) + visualizer = Visualizer(img[:, :, ::-1], metadata=metadata, scale=0.2) + vis = visualizer.draw_dataset_dict(d) + cv2.imwrite('a' + str(l) + '.jpg', (vis.get_image()[:, :, ::-1])) + l+=1 + + + +def train_and_eval(split_rate): + + max_iter = 400 + lr = 0.01 + pictures_dir = os.path.join("..", "data", "originalData", "pictures") + annotations_path = os.path.join(pictures_dir, 'originalAnnotationsTrain.txt') + + split_lines = get_split_lines(annotations_path, split_rate) + + buses_metadata = {} + for d in ['train', 'val']: + DatasetCatalog.register("bus_" + d, lambda d=d: get_bus_dicts(img_dir=pictures_dir, relevant_lines=split_lines[d])) + MetadataCatalog.get("bus_" + d).set(thing_classes=['0', '1', '2', '3', '4', '5']) + buses_metadata[d] = MetadataCatalog.get("bus_" + d) + + ver_type = 'val' + verification(buses_metadata[ver_type], pictures_dir, split_lines[ver_type]) + + net_name = 'faster_rcnn_R_50_FPN_3x' + + print('started training') + train(net_name, True, max_iter, lr) + print('finished training') + + + eval_run_type = 'val' + print('starting evaluation') + eval(buses_metadata[eval_run_type], net_name, pictures_dir, split_lines[eval_run_type]) + print('finished evaluation') + + +def get_split_lines(annotations_path, split_rate): + # Load tagging files + gt_file = open(annotations_path, 'r') + gt_lines = gt_file.readlines() + random.shuffle(gt_lines) + split_index = int(len(gt_lines) * split_rate) + 1 + split_lines = {'train': gt_lines[:split_index], 'val': gt_lines[split_index:]} + + return split_lines + + +if __name__ == '__main__': + train_and_eval(split_rate=SPLIT_RATE) \ No newline at end of file diff --git a/my_imports.py b/my_imports.py new file mode 100644 index 0000000..833388c --- /dev/null +++ b/my_imports.py @@ -0,0 +1,33 @@ +# You may need to restart your runtime prior to this, to let your installation take effect +# Some basic setup +# Setup detectron2 logger +import detectron2 +from detectron2.utils.logger import setup_logger +from detectron2.engine import DefaultTrainer +from detectron2.config import get_cfg +from detectron2.data import DatasetCatalog, MetadataCatalog +import torch, torchvision + +# import some common libraries +import numpy as np +import cv2 +import random +import matplotlib.pyplot as plt + +# import some common detectron2 utilities +from detectron2 import model_zoo +from detectron2.engine import DefaultPredictor +from detectron2.config import get_cfg +from detectron2.utils.visualizer import Visualizer +from detectron2.data import MetadataCatalog +from detectron2.model_zoo.model_zoo import get_config_file +from detectron2.utils.visualizer import ColorMode +setup_logger() + +import os +import json +from detectron2.structures import BoxMode +import itertools +import re + +from consts import * \ No newline at end of file diff --git a/my_utils.py b/my_utils.py new file mode 100644 index 0000000..c51485a --- /dev/null +++ b/my_utils.py @@ -0,0 +1,54 @@ +from my_imports import * + +def find_line_index(lines, name): + ''' + This function finds the index of last line that contains the given name. if + there is not one - the function will return -1. + Inputs: + lines - An arrays of strings + name - name to be search + output: + k0 - An integer which indicates in which line the last name appears. if + it doesn't appear at all it will return -1. + ''' + k0 = -1 + for k in range(len(lines)): + line = lines[k] + if name in line: + k0 = k + return k0 + + +def unwrap_tags(line, is_xyxy): + ''' + This function gets the string of a line in the tags txt file, and + returns the line bounding-box 2 coordinates (x1,y1,x2,y2) and the class + of each bounding box tag. if it invalid line it returns Null. + Input: + line - string, which contain the bounding boxes. + Ouput: + boxes - Numpy-array Nx4 which contain for N bounding boxes taggings + in the picture the 2-coordinates for the bounding box + (x1, y1, x2, y2) as floats. + tag_class - returns Nx1 array which contains the class of each box. + ''' + # spec_line = re.sub(img_name+img_suffix+':','', bbox_lines[line]).split()[-1] + if line.find(':') == -1: + print('ERROR') + return + line = line[line.find(':') + 1:-1].split()[-1] + # print(line) + pre_boxes = line.split('],[') + boxes = np.zeros((len(pre_boxes), 5)) + for k in range(len(pre_boxes)): + pre_boxes[k] = re.sub('[[]', '', pre_boxes[k]) + pre_boxes[k] = re.sub('[]]', '', pre_boxes[k]) + tmp = np.array(pre_boxes[k].split(',')).astype(int) + boxes[k] = tmp + + if is_xyxy: + boxes[:, 2] = boxes[:, 0] + boxes[:, 2] + boxes[:, 3] = boxes[:, 1] + boxes[:, 3] + + tag_class = boxes[:, 4].astype(int) + return boxes[:, :-1], tag_class \ No newline at end of file diff --git a/net_methods.py b/net_methods.py new file mode 100644 index 0000000..4d3133d --- /dev/null +++ b/net_methods.py @@ -0,0 +1,52 @@ +from my_imports import * +from my_detectron_main import * + +def train(net_name, download_weights, max_iter, lr): + cfg = get_cfg() + cfg.merge_from_file(get_config_file(NETS[net_name]['config_file'])) + cfg.DATASETS.TRAIN = ("bus_train",) + cfg.DATASETS.TEST = ("bus_val",) + cfg.DATALOADER.NUM_WORKERS = 1 + + if download_weights: + cfg.MODEL.WEIGHTS = NETS[net_name]['download_coco_weights'] + else: + cfg.MODEL.WEIGHTS = NETS[net_name]['local_coco_weights'] + + + cfg.SOLVER.IMS_PER_BATCH = 2 + cfg.SOLVER.BASE_LR = lr + cfg.SOLVER.MAX_ITER = max_iter + cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 + cfg.MODEL.ROI_HEADS.NUM_CLASSES = 6 + + os.makedirs(cfg.OUTPUT_DIR, exist_ok=True) + trainer = DefaultTrainer(cfg) + trainer.resume_or_load(resume=False) + trainer.train() + +def eval(metadata, net_name, pictures_dir, split_lines_eval): + cfg = get_cfg() + + cfg.merge_from_file(get_config_file(NETS[net_name]['config_file'])) + cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 + cfg.MODEL.ROI_HEADS.NUM_CLASSES = 6 + cfg.SOLVER.IMS_PER_BATCH = 2 + cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final.pth") + cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.6 + cfg.DATASETS.TEST = ("bus_val",) + predictor = DefaultPredictor(cfg) + + eval_dataset_dict = get_bus_dicts(pictures_dir, split_lines_eval) + k=0 + for d in random.sample(eval_dataset_dict, 3): + im = cv2.imread(d["file_name"]) + outputs = predictor(im) + v = Visualizer(im[:, :, ::-1], + metadata=metadata, + scale=0.2, + ) + v = v.draw_instance_predictions(outputs["instances"].to("cpu")) + # cv2_imshow(v.get_image()[:, :, ::-1]) + cv2.imwrite('c' + str(k) + '.jpg', (v.get_image()[:, :, ::-1])) + k+=1 \ No newline at end of file diff --git a/runMe.py b/runMe.py new file mode 100644 index 0000000..bca57ea --- /dev/null +++ b/runMe.py @@ -0,0 +1,207 @@ +# Lior Magram - I.D 316113422, Yuval Noam Feinstein - I.D 206197816 +# import some common libraries +import os +import json +import random +import matplotlib.pyplot as plt +import numpy as np +import cv2 +import random +import itertools +import torch, torchvision + +# import some common detectron2 utilities +import detectron2 +from detectron2.utils.logger import setup_logger +from detectron2.engine import DefaultPredictor +from detectron2.config import get_cfg +from detectron2.utils.visualizer import Visualizer +from detectron2.data import DatasetCatalog, MetadataCatalog +from detectron2.structures import BoxMode +from detectron2.model_zoo.model_zoo import get_config_file + + +# def run1(myAnnFileName, buses): +# +# annFileNameGT = os.path.join(os.getcwd(),'annotationsTrain.txt') +# writtenAnnsLines = {} +# annFileEstimations = open(myAnnFileName, 'w+') +# annFileGT = open(annFileNameGT, 'r') +# writtenAnnsLines['Ground_Truth'] = (annFileGT.readlines()) +# +# for k, line_ in enumerate(writtenAnnsLines['Ground_Truth']): +# +# line = line_.replace(' ','') +# imName = line.split(':')[0] +# anns_ = line[line.index(':') + 1:].replace('\n', '') +# anns = ast.literal_eval(anns_) +# if (not isinstance(anns, tuple)): +# anns = [anns] +# corruptAnn = [np.round(np.array(x) + np.random.randint(low = 0, high = 100, size = 5)) for x in anns] +# corruptAnn = [x[:4].tolist() + [anns[i][4]] for i,x in enumerate(corruptAnn)] +# strToWrite = imName + ':' +# if(3 <= k <= 5): +# strToWrite += '\n' +# else: +# for i, ann in enumerate(corruptAnn): +# posStr = [str(x) for x in ann] +# posStr = ','.join(posStr) +# strToWrite += '[' + posStr + ']' +# if (i == int(len(anns)) - 1): +# strToWrite += '\n' +# else: +# strToWrite += ',' +# annFileEstimations.write(strToWrite) +# return + +def load_Base_RCNN_FPN(): + cfg = get_cfg() + #cfg.merge_from_file(get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")) + # Adding Base-RCNN-FPN configurations + cfg.MODEL.META_ARCHITECTURE = "GeneralizedRCNN" + cfg.MODEL.BACKBONE.NAME = "build_resnet_fpn_backbone" + cfg.MODEL.RESNETS.OUT_FEATURES = ["res2", "res3", "res4", "res5"] + cfg.MODEL.FPN.IN_FEATURES = ["res2", "res3", "res4", "res5"] + cfg.MODEL.ANCHOR_GENERATOR.SIZES = [[32], [64], [128], [256], [512]] # One size for each in feature map + cfg.MODEL.ANCHOR_GENERATOR.ASPECT_RATIOS = [[0.5, 1.0, 2.0]] + cfg.MODEL.RPN.IN_FEATURES = ["p2", "p3", "p4", "p5", "p6"] + cfg.MODEL.RPN.PRE_NMS_TOPK_TRAIN = 2000 # Per FPN Level + cfg.MODEL.RPN.PRE_NMS_TOPK_TEST = 1000 # Per FPN Level + cfg.MODEL.RPN.POST_NMS_TOPK_TRAIN = 1000 + cfg.MODEL.RPN.POST_NMS_TOPK_TEST = 1000 + cfg.MODEL.ROI_HEADS.NAME = "StandardROIHeads" + cfg.MODEL.ROI_HEADS.IN_FEATURES = ["p2", "p3", "p4", "p5"] + cfg.MODEL.ROI_BOX_HEAD.NAME = "FastRCNNConvFCHead" + cfg.MODEL.ROI_BOX_HEAD.NUM_FC = 2 + cfg.MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION = 7 + cfg.MODEL.ROI_MASK_HEAD.NAME = "MaskRCNNConvUpsampleHead" + cfg.MODEL.ROI_MASK_HEAD.NUM_CONV = 4 + cfg.MODEL.ROI_MASK_HEAD.POOLR_RESOLUTION = 14 + cfg.DATASETS.TRAIN = ("coco_2017_train",) + cfg.DATASETS.TEST = ("coco_2017_val",) + cfg.SOLVER.IMS_PER_BATCH = 16 + cfg.SOLVER.BASE_LR = 0.02 + cfg.SOLVER.STEPS = (60000, 80000) + cfg.SOLVER.MAX_ITER = 90000 + cfg.INPUT.MIN_SIZE_TRAIN = (640, 672, 704, 736, 768, 800) + return cfg + + +def buses_predict(pred_obj, img): + im_outputs = pred_obj(img) + num_instances = len(im_outputs["instances"]) + boxes = im_outputs["instances"].get("pred_boxes").tensor + classes = im_outputs["instances"].get("pred_classes") + return boxes, classes, num_instances + + +def get_img_str(im_outputs, img_name, parse_cfg=None): + ''' + This function gets the outputs of specific image from the preditor, and based on the cfg parses the outputs + by the given format [X1, Y1, W, H, Class]. + :param im_outputs: The networks outputs after applying the image on the predictor. + :param img_name: The name of the given image. + :param parse_cfg: The configuration of the parsing, containing 3 settings: shifiting, XYXY or XYWH and integer + output of the location: + cls_shifted - Our network is predicting color class between 0 to 5. if this setting is True, the + parsing will shift the class to be in the range 1 to 6. + is_XYXY - This setting will determine if the given prediction output from the NN is in + [X1,Y1,X2,Y2] format or in [X1,Y1,W,H] format. if is_XYXY is True it will convert + it to [X1,Y1,W,H] format, else it will keep it in [X1,Y1,W,H] format. + is_int - Will determind if the [X1,Y1,W,H] will be parsed as integer or as floats. If it's + True, it will round the [X1,Y1,W,H] values, else it will parse it as floats (As the + predictor outputs get from the predictor function). + :return: to_prnt - A string which contains the estimated annotation of the given image from our predictor in the + Course's format of [X1, Y1, W, H, Class]. + ''' + to_prnt = '' + + # Loading the parsing configuration if given. + if parse_cfg == None: # Default parsing configuration + cls_shifted = True # Change from class range of 0-5 to a class range of 1-6 + is_XYXY = False # The predictor output format is [X1,Y1,W,H] + is_int = True # Parse to integers representation + else: + cls_shifted, is_XYXY, is_int = parse_cfg # Customize parsing configuration + + img_name = img_name.upper() + to_prnt = to_prnt + img_name + ':' + boxes, classes, num_instances = im_outputs + if is_int: + boxes = torch.round(boxes) + if cls_shifted: + classes = classes + 1 # Updating to range 1 to 6 clases + if not is_XYXY: + boxes[:, 2] = boxes[:, 2] - boxes[:, 0] + boxes[:, 3] = boxes[:, 3] - boxes[:, 1] + + for k in range(num_instances): + obj_str = '' + box = boxes[k] + cl = classes[k] + x1_bus, y1_bus, w_bus, h_bus = box + if is_int: + obj_str = '[%d,%d,%d,%d,%d],' % (x1_bus, y1_bus, w_bus, h_bus, cl) + else: + obj_str = '[%f,%f,%f,%f,%d],' % (x1_bus, y1_bus, w_bus, h_bus, cl) + to_prnt = to_prnt + obj_str + + if num_instances: + to_prnt = to_prnt[:-1] + return to_prnt + + +def run(myAnnFileName, bus_dir): + ''' + run - This function gets the myAnnFilename (with path) and buses directory path and calculates the buses + estimation for each image in the buses directory and saves all of the estimation into the an annotation + file (myAnnFileName) with the given format: the name of the image in the beginning of the line, + and then for each bus estimation will be presented as [X1, Y1, W, H, Class]. + The run function uses the buses_predict(img_path) function from our detectron file: + buses_predict(img_path) - The function located at our detectron2 file. This function get an image path + and eval the buses taggings in the image. it returns the network outputs, in + the network predictor format. + :param myAnnFileName: The path for the annotation file of the estimated images. + :param bus_dir: The path for the buses images directory. + :return: None. + ''' + + setup_logger() + + cfg = load_Base_RCNN_FPN() + + # Adding COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml" configurations + cfg.MODEL.MASK_ON = False + cfg.MODEL.RESNETS.DEPTH = 50 + cfg.SOLVER.MAX_ITER = 270000 + cfg.SOLVER.STEPS = (210000, 250000) + + # Adding additional non-default configurations + cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "weights_f1_1.000000_lr_0.008000_iter_450_ther_0.800000.pth") + + cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.8 + cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 + cfg.MODEL.ROI_HEADS.NUM_CLASSES = 6 + cfg.DATASETS.TEST = ("bus_val",) + # cfg.TEST.AUG.ENABLED = True + + predictor = DefaultPredictor(cfg) + annFileEstimations = open(myAnnFileName, 'w+') + for file_name in os.listdir(bus_dir): + if file_name.endswith(".JPG"): + img_path = os.path.join(bus_dir, file_name) + file_name = file_name.upper() + print(file_name) + img = cv2.imread(img_path) + pred_outputs = buses_predict(predictor, img) + pred_parsed = get_img_str(pred_outputs, file_name) + annFileEstimations.write(pred_parsed + '\n') + annFileEstimations.close() + + return + +# if __name__ == '__main__': +# ann_file = os.path.join('test_output.txt') +# bus_dir = os.path.join("data","val") +# # bus_dir = os.path.join("..","toyData","val") +# run(ann_file, bus_dir) diff --git a/run_pretrained.py b/run_pretrained.py new file mode 100644 index 0000000..7267f66 --- /dev/null +++ b/run_pretrained.py @@ -0,0 +1,78 @@ +# You may need to restart your runtime prior to this, to let your installation take effect +# Some basic setup +# Setup detectron2 logger +import detectron2 +from detectron2.utils.logger import setup_logger +setup_logger() + +# import some common libraries +import numpy as np +import cv2 +import random +# from google.colab.patches import cv2_imshow +import os +# import some common detectron2 utilities +from detectron2 import model_zoo +from detectron2.engine import DefaultPredictor +from detectron2.config import get_cfg +from detectron2.utils.visualizer import Visualizer +from detectron2.data import MetadataCatalog +from detectron2.model_zoo.model_zoo import get_config_file +import matplotlib.pyplot as plt +from detectron2_tutorial import * + + +def main(): + # im = cv2.imread(os.path.join("data", "originalData", "pictures", "DSCF1013.JPG")) + + + cfg = get_cfg() + + model = 'detection' + + if model == 'instance-segmentation': + pass + # add project-specific config (e.g., TensorMask) here if you're not running a model in detectron2's core library + cfg.merge_from_file(get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) + # cfg.MODEL.MASK_ON = False + cfg.MODEL.WEIGHTS = "model_final_f10217.pkl" + elif model == 'detection': + cfg.merge_from_file(get_config_file("COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml")) + cfg.MODEL.WEIGHTS = "model_final_68b088.pkl" + + # cfg.merge_from_file(get_config_file("COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")) + # cfg.MODEL.WEIGHTS = "model_final_280758.pkl" + + # cfg.merge_from_file(get_config_file("COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml")) + # cfg.MODEL.WEIGHTS = "model_final_b275ba.pkl" + + # cfg.MODEL.LOAD_PROPOSALS = False + cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5 # set threshold for this model + # Find a model from detectron2's model zoo. You can either use the https://dl.fbaipublicfiles.... url, or use the detectron2:// shorthand + predictor = DefaultPredictor(cfg) + + + # We can use `Visualizer` to draw the predictions on the image. + pictures_path = os.path.join("..", "data", "originalData", "pictures") + images_filenames = os.listdir(pictures_path) + output_path = os.path.join("..", "data", "originalData", "output_pictures") + if not os.path.exists(output_path): + os.mkdir(output_path) + + for idx, image_filename in enumerate(images_filenames): + im = cv2.imread(os.path.join("data", 'originalData', 'pictures', image_filename)) + + outputs = predictor(im) + + # look at the outputs. See https://detectron2.readthedocs.io/tutorials/models.html#model-output-format for specification + outputs["instances"].pred_classes + outputs["instances"].pred_boxes + + v = Visualizer(im[:, :, ::-1], MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2) + v = v.draw_instance_predictions(outputs["instances"].to("cpu")) + image_output_path = os.path.join(output_path, 'pred_x101_' + image_filename) + plt.imsave(image_output_path, v.get_image()[:, :, ::-1]) + # cv2.imsave('funny.jpg', v.get_image()[:, :, ::-1]) + +if __name__ == '__main__': + main() \ No newline at end of file