def __getitem__(self, idx): epiInd = 0 # calculate the epiInd while idx >= self.episodeNum[epiInd]: # print self.episodeNum[epiInd], epiInd += 1 if epiInd > 0: idx -= self.episodeNum[epiInd - 1] # random fliping flipping = False if self.aug and random.random() > 0.5: flipping = True # print epiInd, idx imgseq = [] for k in range(self.batch): img = cv2.imread(self.imgnamelist[epiInd][idx + k]) if self.aug: img = im_hsv_augmentation(img) img = im_crop(img) outimg = im_scale_norm_pad(img, outsize=self.imgsize, mean=self.mean, std=self.std, down_reso=True, flip=flipping) imgseq.append(outimg) return np.array(imgseq)
def augment_image(self, img, flipping): # augment image to make "new" data if self.aug: img = utils.im_hsv_augmentation(img) img = utils.im_crop(img, maxscale=self.maxscale) out_img = utils.im_scale_norm_pad( img, self.mean, self.std, out_size=self.img_size, # down_reso=True, flip=flipping) return out_img
def __getitem__(self, idx): img = cv2.imread(self.imgnamelist[idx]) # in bgr label = np.array(self.labellist[idx], dtype=np.float32) # random fliping flipping = False if self.aug and random.random() > 0.5: flipping = True label[1] = -label[1] if self.aug: img = im_hsv_augmentation(img) img = im_crop(img, maxscale=self.maxscale) outimg = im_scale_norm_pad(img, outsize=self.imgsize, mean=self.mean, std=self.std, down_reso=True, flip=flipping) return {'img': outimg, 'label': label}
def __getitem__(self, idx): epiInd = 0 # calculate the epiInd while idx >= self.episodeNum[epiInd]: # print self.episodeNum[epiInd], epiInd += 1 if epiInd > 0: idx -= self.episodeNum[epiInd - 1] # random fliping flipping = False if self.aug and random.random() > 0.5: flipping = True # print epiInd, idx imgseq = [] labelseq = [] for k in range(self.batch): img = cv2.imread(self.imgnamelist[epiInd][idx + k][0]) angle = self.imgnamelist[epiInd][idx + k][1] direction_angle_cos = np.cos(float(angle)) direction_angle_sin = np.sin(float(angle)) label = np.array([direction_angle_sin, direction_angle_cos], dtype=np.float32) if self.aug: img = im_hsv_augmentation(img) img = im_crop(img) if flipping: label[1] = -label[1] outimg = im_scale_norm_pad(img, outsize=self.imgsize, mean=self.mean, std=self.std, down_reso=True, flip=flipping) imgseq.append(outimg) labelseq.append(label) return {'imgseq': np.array(imgseq), 'labelseq': np.array(labelseq)}
def __getitem__(self, idx): if self.filename[-3:] == 'csv': point_info = self.items.iloc[idx] else: point_info = self.items[idx] #print(point_info) img_name = point_info['path'] direction_angle = point_info['direction_angle'] direction_angle_cos = np.cos(float(direction_angle)) direction_angle_sin = np.sin(float(direction_angle)) label = np.array([direction_angle_sin, direction_angle_cos], dtype=np.float32) img = cv2.imread(img_name) # random fliping flipping = False if self.aug and random.random() > 0.5: flipping = True label[1] = -label[1] if img is None: print 'error image:', img_name return if self.aug: img = im_hsv_augmentation(img, Hscale=10, Sscale=60, Vscale=60) img = im_crop(img, maxscale=self.maxscale) outimg = im_scale_norm_pad(img, outsize=self.imgsize, mean=self.mean, std=self.std, down_reso=True, flip=flipping) return {'img': outimg, 'label': label}
iy = F.ix facesy = F.bbox # for all enrolled images for i in range(n): X = extract_rows(D, ix, i) # descriptors of subject i # computation of scores between enrolled faces and session images scr, scr_best, ind_best, face_detected = vector_distances( Y, X.T, sc_method, theta, print_scr) F.scores[i][j] = scr_best # construction of output image with the recognized faces per subject in each session if show_img == 1: if face_detected == 1: ii = ind_best[0] jj = iy[ind_best[0]].item() image = im_crop(img_path_session + img_names_session[jj], facesy[ii], 0) else: image = [] image_session = im_concatenate(image_session, image, img_size, 0) if show_img == 1: image_final = im_concatenate(image_final, image_session, img_size_f, 1) image_session = [] # assistance report if show_img == 1: imshow(image_final) F.reportAssistance()