Stinky-Tofu / Stronger-yolo

🔥Improve yolo with latest paper
MIT License
3 stars 0 forks source link

data.py改了点代码,把不合法的bbox先修剪,修剪后还不行的忽略掉了。 #41

Open wizholy opened 5 years ago

wizholy commented 5 years ago

def __parse_annotation(self, annotation): line = annotation.split() image_path = line[0] image = np.array(cv2.imread(image_path)) bboxes = np.array([map(int, box.split(',')) for box in line[1:]]) image, bboxes = data_aug.random_horizontal_flip(np.copy(image), np.copy(bboxes)) image, bboxes = data_aug.random_crop(np.copy(image), np.copy(bboxes)) image, bboxes = data_aug.random_translate(np.copy(image), np.copy(bboxes)) image, bboxes = utils.img_preprocess2(np.copy(image), np.copy(bboxes), (self.train_input_size, self.train_input_size), True) bboxes_temp=[] bboxes[:,0:4]=np.maximum(bboxes[:,0:4],0) bboxes[:,0:4]=np.minimum(bboxes[:,0:4],image.shape[0]) for bbox in bboxes: if bbox[0]>=bbox[2] or bbox[1]>=bbox[3]: continue if bbox[0]>image.shape[0] or bbox[1]>image.shape[1]: continue bboxes_temp.append(bbox) return image, np.array(bboxes_temp)