Fixed seg-fault that occurred if <class_id> in labels more than classes= in the cfg-file.
| | |
| | | int best_class_id = -1; |
| | | for(t = 0; t < l.max_boxes; ++t){ |
| | | box truth = float_to_box(state.truth + t*5 + b*l.truths); |
| | | int class_id = state.truth[t * 5 + 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(!truth.x) break; |
| | | float iou = box_iou(pred, truth); |
| | | if (iou > best_iou) { |
| | |
| | | } |
| | | for(t = 0; t < l.max_boxes; ++t){ |
| | | box truth = float_to_box(state.truth + t*5 + b*l.truths); |
| | | int class_id = state.truth[t * 5 + 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(!truth.x) break; |
| | | float best_iou = 0; |
| | |
| | | l.delta[best_index + 4] = l.object_scale * (iou - l.output[best_index + 4]) * logistic_gradient(l.output[best_index + 4]); |
| | | } |
| | | |
| | | |
| | | int class_id = state.truth[t*5 + b*l.truths + 4]; |
| | | if (l.map) class_id = l.map[class_id]; |
| | | delta_region_class(l.output, l.delta, best_index + 5, class_id, l.classes, l.softmax_tree, l.class_scale, &avg_cat, l.focal_loss); |
| | | ++count; |
| | |
| | | int best_t = 0; |
| | | for(t = 0; t < l.max_boxes; ++t){ |
| | | 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]; |
| | | if (class_id >= l.classes) continue; // if label contains class_id more than number of classes in the cfg-file |
| | | if(!truth.x) break; |
| | | float iou = box_iou(pred, truth); |
| | | if (iou > best_iou) { |
| | |
| | | if (best_iou > l.truth_thresh) { |
| | | l.delta[obj_index] = 1 - l.output[obj_index]; |
| | | |
| | | int class = state.truth[best_t*(4 + 1) + b*l.truths + 4]; |
| | | if (l.map) class = l.map[class]; |
| | | int class_id = state.truth[best_t*(4 + 1) + b*l.truths + 4]; |
| | | if (l.map) class_id = l.map[class_id]; |
| | | int class_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, 4 + 1); |
| | | delta_yolo_class(l.output, l.delta, class_index, class, l.classes, l.w*l.h, 0, l.focal_loss); |
| | | delta_yolo_class(l.output, l.delta, class_index, class_id, l.classes, l.w*l.h, 0, l.focal_loss); |
| | | box truth = float_to_box_stride(state.truth + best_t*(4 + 1) + b*l.truths, 1); |
| | | delta_yolo_box(truth, l.output, l.biases, l.mask[n], box_index, i, j, l.w, l.h, state.net.w, state.net.h, l.delta, (2-truth.w*truth.h), l.w*l.h); |
| | | } |
| | |
| | | } |
| | | for(t = 0; t < l.max_boxes; ++t){ |
| | | 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]; |
| | | if (class_id >= l.classes) continue; // if label contains class_id more than number of classes in the cfg-file |
| | | |
| | | if(!truth.x) break; |
| | | float best_iou = 0; |
| | |
| | | avg_obj += l.output[obj_index]; |
| | | l.delta[obj_index] = 1 - l.output[obj_index]; |
| | | |
| | | int class = state.truth[t*(4 + 1) + b*l.truths + 4]; |
| | | if (l.map) class = l.map[class]; |
| | | int class_id = state.truth[t*(4 + 1) + b*l.truths + 4]; |
| | | if (l.map) class_id = l.map[class_id]; |
| | | int class_index = entry_index(l, b, mask_n*l.w*l.h + j*l.w + i, 4 + 1); |
| | | delta_yolo_class(l.output, l.delta, class_index, class, l.classes, l.w*l.h, &avg_cat, l.focal_loss); |
| | | delta_yolo_class(l.output, l.delta, class_index, class_id, l.classes, l.w*l.h, &avg_cat, l.focal_loss); |
| | | |
| | | ++count; |
| | | ++class_count; |