Skip to content

Commit

Permalink
Bug is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Jul 27, 2020
1 parent 49bff0e commit 139fe14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ void draw_detections_v3(image im, detection *dets, int num, float thresh, char *
if (alphabet) {
char labelstr[4096] = { 0 };
strcat(labelstr, names[selected_detections[i].best_class]);
char prob_str[10];
sprintf(prob_str, ": %.2f", selected_detections[i].det.prob[selected_detections[i].best_class]);
strcat(labelstr, prob_str);
int j;
for (j = 0; j < classes; ++j) {
if (selected_detections[i].det.prob[j] > thresh && j != selected_detections[i].best_class) {
Expand Down
17 changes: 9 additions & 8 deletions src/region_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ region_layer make_region_layer(int batch, int w, int h, int n, int classes, int
l.outputs = h*w*n*(classes + coords + 1);
l.inputs = l.outputs;
l.max_boxes = max_boxes;
l.truths = max_boxes*(5);
l.truth_size = 4 + 2;
l.truths = max_boxes*l.truth_size;
l.delta = (float*)xcalloc(batch * l.outputs, sizeof(float));
l.output = (float*)xcalloc(batch * l.outputs, sizeof(float));
int i;
Expand Down Expand Up @@ -226,9 +227,9 @@ void forward_region_layer(const region_layer l, network_state state)
if(l.softmax_tree){
int onlyclass_id = 0;
for(t = 0; t < l.max_boxes; ++t){
box truth = float_to_box(state.truth + t*5 + b*l.truths);
box truth = float_to_box(state.truth + t*l.truth_size + b*l.truths);
if(!truth.x) break; // continue;
int class_id = state.truth[t*5 + b*l.truths + 4];
int class_id = state.truth[t*l.truth_size + b*l.truths + 4];
float maxp = 0;
int maxi = 0;
if(truth.x > 100000 && truth.y > 100000){
Expand Down Expand Up @@ -258,13 +259,13 @@ void forward_region_layer(const region_layer l, network_state state)
float best_iou = 0;
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];
box truth = float_to_box(state.truth + t*l.truth_size + b*l.truths);
int class_id = state.truth[t * l.truth_size + 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; // continue;
float iou = box_iou(pred, truth);
if (iou > best_iou) {
best_class_id = state.truth[t*5 + b*l.truths + 4];
best_class_id = state.truth[t*l.truth_size + b*l.truths + 4];
best_iou = iou;
}
}
Expand Down Expand Up @@ -297,8 +298,8 @@ void forward_region_layer(const region_layer l, network_state state)
}
}
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];
box truth = float_to_box(state.truth + t*l.truth_size + b*l.truths);
int class_id = state.truth[t * l.truth_size + b*l.truths + 4];
if (class_id >= l.classes) {
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);
getchar();
Expand Down

0 comments on commit 139fe14

Please sign in to comment.