experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 785 forks source link

Evaluation for empty annotation #368

Open artest08 opened 5 years ago

artest08 commented 5 years ago

I have noticed something but I am not sure,

in preprocessing part, in load annotations, there is a line that if len(annots) == 0: annots = [[]] then, this is converted to numpy array.

This is used in Frontend in the evaluation part which is the line all_annotations[i][label] = annotations[annotations[:, 4] == label, :4].copy()

Therefore, when the code tries to reach annotations[:, 4], it pops out an error, I think.

Moreover, np.array([[]]) has a shape of (1,0), in the following part, for the empty annotations, if annotations.shape[0] == 0: is added. However, because of the shape of (1,0), that part probably wont make what is intended.

I may miss some points, if I am misunderstood something or I am wrong, please correct me. Thanks in advance

jzx-gooner commented 5 years ago

@artest08 i have the some confused when i want add some negative dataset(without object) in could you solve this problem?

artest08 commented 5 years ago

Sorry for my late response,

I have made a little change in frontend which is for label in range(generator.num_classes()): if np.array_equal(annotations, np.array([[]])): all_annotations[i][label]=annotations.T else: all_annotations[i][label] = annotations[annotations[:, 4] == label, :4].copy()

Instead of for label in range(generator.num_classes()): all_annotations[i][label] = annotations[annotations[:, 4] == label, :4].copy()

It seems to work but I am not sure whether it is the correct way or not