Open h030162 opened 4 years ago
hi! can you solved this problem?
bbox=[]
labels=[]
emptybbox=[[10,10,100,100]]
emptylabels=[[0]]
if len(target) > 0:
bbox = target[:, :4]
for i in range(len(bbox)):
bbox[i, 0] = bbox[i, 0] if bbox[i, 0] < width else width
bbox[i, 1] = bbox[i, 1] if bbox[i, 1] < height else height
bbox[i, 2] = bbox[i, 2] if bbox[i, 2] < width else width
bbox[i, 3] = bbox[i, 3] if bbox[i, 3] < height else height
for j in range(len(bbox[i])):
bbox[i,j] = bbox[i,j] if bbox[i,j] > 0 else 0
labels = target[:, 4]
if self.transform is not None:
if len(bbox) > 0:
#print("len(bbox)", bbox, img.shape)
annotation = {'image': img, 'bboxes': bbox, 'category_id': labels}
augmentation = self.transform(**annotation)
img = augmentation['image']
bbox = augmentation['bboxes']
labels = augmentation['category_id']
else:
#print("len(bbox)2", bbox)
annotation1 = {'image': img, 'bboxes': emptybbox, 'category_id': emptylabels}
augmentation = self.transform(**annotation1)
img = augmentation['image']
return {'image': img, 'bboxes': bbox, 'category_id': labels}
it's my code. I'm not sure this is right or not.
hi! thanks for your great work. target = np.array(target) bbox = target[:, :4] labels = target[:, 4]
when nothing to labeled, target shape is (0,) in this time how to do? thank you again