Commit c7590c41 authored by Jonas Müller's avatar Jonas Müller

annotate GT in test_images too

parent c622eb29
20190507_113350.jpg,caries,1651,1403,2063,1651
20190507_113350.jpg,caries,2311,1486,2559,1651
20190507_113350.jpg,caries,2063,1403,2311,1651
20190507_113350.jpg,caries,1568,1403,1651,1651
20190507_113350.jpg,caries,1651,1403,1816,1568
20190507_113350.jpg,caries,3054,412,3219,577
20190510_114803.jpg,caries,2559,1733,2889,1898
20190510_114803.jpg,caries,743,1403,990,1651
20190510_114803.jpg,caries,2476,1733,2807,1898
20190510_114803.jpg,caries,2559,1733,2972,1898
20190523_095739.jpg,caries,412,990,825,1238
20190523_095739.jpg,caries,0,2724,247,3054
20190523_101812.jpg,caries,1486,1073,1651,1320
20190510_114803.jpg,caries,2559,1651,2889,1816
20190510_114803.jpg,caries,743,1486,908,1651
20190523_095717.jpg,caries,1651,1651,1981,1898
20190523_095739.jpg,caries,412,990,743,1238
20190523_095739.jpg,caries,0,2724,247,2972
20190523_101016.jpg,caries,3962,1073,4045,1238
20190523_101016.jpg,caries,1898,1238,2229,1403
20190523_101016.jpg,caries,3962,1155,4045,1238
20190523_101016.jpg,caries,3880,908,3962,990
20190523_101016.jpg,caries,3962,1073,4045,1155
20190523_101812.jpg,caries,1403,1073,1651,1238
20190523_101812.jpg,caries,2889,1155,3054,1238
20190523_111037.jpg,caries,1238,2063,1320,2146
20190523_111037.jpg,caries,1073,1733,1238,1898
IMG_20190223_110731.jpg,caries,361,657,492,755
IMG_20190223_110731.jpg,caries,1379,328,1478,394
IMG_20190223_110731.jpg,caries,262,394,394,492
IMG_20190223_110731.jpg,caries,361,657,525,722
IMG_20190223_110731.jpg,caries,328,328,427,394
IMG_20190223_110731.jpg,caries,262,394,394,525
IMG_20190223_110731.jpg,caries,295,328,394,394
IMG_20190223_110731.jpg,caries,1281,689,1412,755
IMG_20190330_101819.jpg,caries,3455,2211,3732,2419
IMG_20190330_101819.jpg,caries,3179,967,3386,1244
IMG_20190330_101819.jpg,caries,3248,1451,3594,1797
IMG_20190330_101819.jpg,caries,1175,1105,1520,1313
IMG_20190330_101819.jpg,caries,1589,691,1935,967
IMG_20190330_101819.jpg,caries,3455,2142,3732,2350
IMG_20190223_110731.jpg,caries,394,689,525,755
IMG_20190223_110731.jpg,caries,1314,689,1379,755
IMG_20190330_101819.jpg,caries,1105,1175,1313,1313
IMG_20190330_101819.jpg,caries,3455,2142,3732,2419
IMG_20190330_101819.jpg,caries,3248,1520,3594,1797
IMG_20190330_101819.jpg,caries,1658,691,1935,967
IMG_20190330_101819.jpg,caries,3179,967,3386,1313
IMG_20190330_101819.jpg,caries,3386,1935,3663,2073
IMG_20190330_101819.jpg,caries,3317,1313,3594,1520
IMG_20190404_103747.jpg,caries,3248,967,3317,1036
IMG_20190404_121332.jpg,caries,552,2903,760,3110
IMG_20190404_121332.jpg,caries,898,1866,1175,2004
IMG_20190404_123358.jpg,caries,829,3179,1105,3386
IMG_20190404_123358.jpg,caries,1105,3386,1382,3594
IMG_20190404_123358.jpg,caries,1036,2073,1313,2280
IMG_20190404_123358.jpg,caries,1105,3317,1382,3594
IMG_20190404_123358.jpg,caries,1451,2073,1727,2280
IMG_20190404_123358.jpg,caries,1451,2073,1727,2350
IMG_20190404_125829.jpg,caries,3594,691,3732,829
IMG_20190404_125829.jpg,caries,2419,898,2626,1036
......@@ -6,7 +6,7 @@ import sys
import pickle
from optparse import OptionParser
import time
from keras_frcnn import config
from keras_frcnn import config, simple_parser
from keras import backend as K
from keras.layers import Input
from keras.models import Model
......@@ -141,7 +141,7 @@ model_classifier.load_weights(C.model_path, by_name=True)
model_rpn.compile(optimizer='sgd', loss='mse')
model_classifier.compile(optimizer='sgd', loss='mse')
all_imgs = []
all_imgs, _ , _ = simple_parser.get_data('data/annotations_test.txt')
classes = {}
......@@ -150,8 +150,17 @@ bbox_threshold = 0.8
visualise = True
output = open('data/test_output.txt','w')
file_list = sorted(os.listdir(img_path))
all_imgs_annot = {}
for idx, img_name in enumerate(sorted(os.listdir(img_path))):
for file in file_list:
for one_gt_entry in all_imgs:
if one_gt_entry['filepath'].endswith(file):
all_imgs_annot[file] = one_gt_entry
break
for idx, img_name in enumerate(file_list):
if not img_name.lower().endswith(('.bmp', '.jpeg', '.jpg', '.png', '.tif', '.tiff')):
continue
print(img_name)
......@@ -224,6 +233,20 @@ for idx, img_name in enumerate(sorted(os.listdir(img_path))):
all_dets = []
# add Ground truth as base overlay
for bbox in all_imgs_annot[img_name]['bboxes']:
cv2.rectangle(img, (bbox['x1'], bbox['y1']), (bbox['x2'], bbox['y2']), (0, 0, 0), 2)
textLabel = '{}: GT'.format(bbox['class'])
(retval, baseLine) = cv2.getTextSize(textLabel, cv2.FONT_HERSHEY_COMPLEX, 1, 1)
textOrg = (bbox['x1'], bbox['y1'] - 0)
cv2.rectangle(img, (textOrg[0] - 5, textOrg[1] + baseLine - 5),
(textOrg[0] + retval[0] + 5, textOrg[1] - retval[1] - 5), (0, 0, 0), 2)
cv2.rectangle(img, (textOrg[0] - 5, textOrg[1] + baseLine - 5),
(textOrg[0] + retval[0] + 5, textOrg[1] - retval[1] - 5), (255, 255, 255), -1)
cv2.putText(img, textLabel, textOrg, cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 0), 1)
for key in bboxes:
bbox = np.array(bboxes[key])
......@@ -249,5 +272,6 @@ for idx, img_name in enumerate(sorted(os.listdir(img_path))):
print(all_dets)
# cv2.imshow('img', img)
# cv2.waitKey(0)
cv2.imwrite('data/results_imgs/{}.png'.format(idx),img)
#cv2.imwrite('data/results_imgs/{}.png'.format(idx),img)
cv2.imwrite('data/results_imgs/{}.png'.format(img_name), img)
output.close()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment