Merge pull request #5002 from mandoo92/master

Class_id Garbage Value Check
pull/4976/head
Alexey 5 years ago committed by GitHub
commit e70b70db8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/yolo_layer.c

@ -374,11 +374,11 @@ void forward_yolo_layer(const layer l, network_state state)
for (t = 0; t < l.max_boxes; ++t) { for (t = 0; t < l.max_boxes; ++t) {
box truth = float_to_box_stride(state.truth + t*(4 + 1) + b*l.truths, 1); box truth = float_to_box_stride(state.truth + t*(4 + 1) + b*l.truths, 1);
int class_id = state.truth[t*(4 + 1) + b*l.truths + 4]; int class_id = state.truth[t*(4 + 1) + b*l.truths + 4];
if (class_id >= l.classes) { if (class_id >= l.classes || class_id < 0) {
printf("\n Warning: in txt-labels class_id=%d >= classes=%d in cfg-file. In txt-labels class_id should be [from 0 to %d] \n", class_id, l.classes, l.classes - 1); printf("\n Warning: in txt-labels class_id=%d >= classes=%d in cfg-file. In txt-labels class_id should be [from 0 to %d] \n", class_id, l.classes, l.classes - 1);
printf("\n truth.x = %f, truth.y = %f, truth.w = %f, truth.h = %f, class_id = %d \n", truth.x, truth.y, truth.w, truth.h, class_id); printf("\n truth.x = %f, truth.y = %f, truth.w = %f, truth.h = %f, class_id = %d \n", truth.x, truth.y, truth.w, truth.h, class_id);
if (check_mistakes) getchar(); if (check_mistakes) getchar();
continue; // if label contains class_id more than number of classes in the cfg-file continue; // if label contains class_id more than number of classes in the cfg-file and class_id check garbage value
} }
if (!truth.x) break; // continue; if (!truth.x) break; // continue;
@ -427,7 +427,7 @@ void forward_yolo_layer(const layer l, network_state state)
system(buff); system(buff);
} }
int class_id = state.truth[t*(4 + 1) + b*l.truths + 4]; int class_id = state.truth[t*(4 + 1) + b*l.truths + 4];
if (class_id >= l.classes) continue; // if label contains class_id more than number of classes in the cfg-file if (class_id >= l.classes || class_id < 0) continue; // if label contains class_id more than number of classes in the cfg-file and class_id check garbage value
if (!truth.x) break; // continue; if (!truth.x) break; // continue;
float best_iou = 0; float best_iou = 0;

Loading…
Cancel
Save