def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 hand_color1 = np.array(hypes['data']['hand_color1']) hand_color2 = np.array(hypes['data']['hand_color2']) hand_color3 = np.array(hypes['data']['hand_color3']) hand_color4 = np.array(hypes['data']['hand_color4']) hand_color5 = np.array(hypes['data']['hand_color5']) background_color = np.array(hypes['data']['background_color']) gt_hand1 = np.all(gt_image == hand_color1, axis=2) # TODO: may not exist gt_hand2 = np.all(gt_image == hand_color2, axis=2) # TODO: may not exist gt_hand3 = np.all(gt_image == hand_color3, axis=2) # TODO: may not exist gt_hand4 = np.all(gt_image == hand_color4, axis=2) # TODO: may not exist gt_hand5 = np.all(gt_image == hand_color5, axis=2) # TODO: may not exist gt_hand = gt_hand1 | gt_hand2 | gt_hand3 | gt_hand4 | gt_hand5 gt_bg = np.all(gt_image == background_color, axis=2) # TODO: may not exist valid_gt = gt_hand + gt_bg FN, FP, posNum, negNum = seg.evalExp(gt_hand, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 FN, FP = np.zeros(thresh.shape), np.zeros(thresh.shape) posNum, negNum = 0, 0 colors = [] for key in hypes['colors']: colors.append(np.array(hypes['colors'][key])) valid_gt = np.all(gt_image == colors[0], axis=2) for i in range(1, len(colors)): valid_gt = valid_gt + np.all(gt_image == colors[i], axis=2) for i in range(len(colors)): N, P, pos, neg = seg.evalExp(np.all(gt_image == colors[i], axis=2), cnn_image, thresh, validMap=None, validArea=valid_gt) FN = np.add(FN, N) FP = np.add(FP, P) posNum += pos negNum += neg return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256))/255.0 valid_gt = utils.load_segmentation_mask(hypes, gt_image)[:, :, :-1] return seg.evalExp(hypes, valid_gt, cnn_image)
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 road_gt = gt_image[:, :, 2] > 0 valid_gt = gt_image[:, :, 0] > 0 FN, FP, posNum, negNum = seg.evalExp(road_gt, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256))/255.0 road_color = np.array(hypes['data']['road_color']) background_color = np.array(hypes['data']['background_color']) gt_road = np.all(gt_image == road_color, axis=2) gt_bg = np.all(gt_image == background_color, axis=2) valid_gt = gt_road + gt_bg FN, FP, posNum, negNum = seg.evalExp(gt_road, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 road_color = np.array(hypes['data']['road_color']) background_color = np.array(hypes['data']['background_color']) gt_road = np.all(gt_image == road_color, axis=2) gt_bg = np.all(gt_image == background_color, axis=2) valid_gt = gt_road + gt_bg FN, FP, posNum, negNum = seg.evalExp(gt_road, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 gt_bg = gt_image[:, :, 0] gt_hand = gt_image[:, :, 1] gt_local = gt_image[:, :, 2] valid_gt = gt_bg | gt_hand FN, FP, posNum, negNum = seg.evalExp(gt_local, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 heatmap_color = np.array(hypes['data']['heatmap_color']) background_color = np.array(hypes['data']['background_color']) # calculate the probability of an object of interest location in each pixel gt_obj = np.any(gt_image != background_color, axis=2) gt_bg = np.all(gt_image == background_color, axis=2) valid_gt = gt_obj + gt_bg FN, FP, posNum, negNum = seg.evalExp(gt_obj, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
def eval_image(hypes, gt_image, cnn_image): """.""" thresh = np.array(range(0, 256)) / 255.0 #road_color = np.array(hypes['data']['road_color']) #background_color = np.array(hypes['data']['background_color']) gts = [] for color_name, color in hypes['data']['colors'].items(): gts.append(np.all(gt_image == color, axis=2)) valid_gt = np.sum(gts) # right now this only calculates for the first thing FN, FP, posNum, negNum = seg.evalExp(gts[0], cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum
import tensorvision import tensorvision.utils as utils #evaluate the image def eval_image(hypes, gt_image, cnn_image): thresh = np.array(range(0, 256))/255.0 #get the road color for segmentation red, blue/ green road_color = np.array(hypes['data']['road_color']) #background_color background_color = np.array(hypes['data']['background_color']) gt_road = np.all(gt_image == road_color, axis=2) gt_bg = np.all(gt_image == background_color, axis=2) valid_gt = gt_road + gt_bg FN, FP, posNum, negNum = seg.evalExp(gt_road, cnn_image, thresh, validMap=None, validArea=valid_gt) return FN, FP, posNum, negNum #resize the label image def resize_label_image(image, gt_image, image_height, image_width): #image resize image = scp.misc.imresize(image, size=(image_height, image_width), interp='cubic') shape = gt_image.shape #label resize gt_image = scp.misc.imresize(gt_image, size=(image_height, image_width), interp='nearest') return image, gt_image