mirror of https://github.com/AlexeyAB/darknet.git
max_delta= affects counters_per_class=
This commit is contained in:
parent
dfbf42cfc0
commit
a71b9a6e9a
|
@ -5,6 +5,7 @@ rem Download Yolo9000: http://pjreddie.com/media/files/yolo9000.weights
|
|||
|
||||
rem darknet.exe partial cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights tiny-yolo-voc.conv.13 13
|
||||
|
||||
darknet.exe partial cfg/yolov4-tiny.cfg yolov4-tiny.weights yolov4-tiny.conv.29 29
|
||||
|
||||
|
||||
darknet.exe partial cfg/yolov4-sam-mish.cfg cfg/yolov4-sam-mish.weights cfg/yolov4-sam-mish.conv.137 137
|
||||
|
|
21
src/parser.c
21
src/parser.c
|
@ -386,7 +386,7 @@ int *parse_yolo_mask(char *a, int *num)
|
|||
return mask;
|
||||
}
|
||||
|
||||
float *get_classes_multipliers(char *cpc, const int classes)
|
||||
float *get_classes_multipliers(char *cpc, const int classes, const float max_delta)
|
||||
{
|
||||
float *classes_multipliers = NULL;
|
||||
if (cpc) {
|
||||
|
@ -398,9 +398,15 @@ float *get_classes_multipliers(char *cpc, const int classes)
|
|||
}
|
||||
float max_counter = 0;
|
||||
int i;
|
||||
for (i = 0; i < classes_counters; ++i) if (max_counter < counters_per_class[i]) max_counter = counters_per_class[i];
|
||||
for (i = 0; i < classes_counters; ++i) {
|
||||
if (counters_per_class[i] < 1) counters_per_class[i] = 1;
|
||||
if (max_counter < counters_per_class[i]) max_counter = counters_per_class[i];
|
||||
}
|
||||
classes_multipliers = (float *)calloc(classes_counters, sizeof(float));
|
||||
for (i = 0; i < classes_counters; ++i) classes_multipliers[i] = max_counter / counters_per_class[i];
|
||||
for (i = 0; i < classes_counters; ++i) {
|
||||
classes_multipliers[i] = max_counter / counters_per_class[i];
|
||||
if(classes_multipliers[i] > max_delta) classes_multipliers[i] = max_delta;
|
||||
}
|
||||
free(counters_per_class);
|
||||
printf(" classes_multipliers: ");
|
||||
for (i = 0; i < classes_counters; ++i) printf("%.1f, ", classes_multipliers[i]);
|
||||
|
@ -425,13 +431,13 @@ layer parse_yolo(list *options, size_params params)
|
|||
}
|
||||
//assert(l.outputs == params.inputs);
|
||||
|
||||
l.max_delta = option_find_float_quiet(options, "max_delta", FLT_MAX); // set 10
|
||||
char *cpc = option_find_str(options, "counters_per_class", 0);
|
||||
l.classes_multipliers = get_classes_multipliers(cpc, classes);
|
||||
l.classes_multipliers = get_classes_multipliers(cpc, classes, l.max_delta);
|
||||
|
||||
l.label_smooth_eps = option_find_float_quiet(options, "label_smooth_eps", 0.0f);
|
||||
l.scale_x_y = option_find_float_quiet(options, "scale_x_y", 1);
|
||||
l.objectness_smooth = option_find_int_quiet(options, "objectness_smooth", 0);
|
||||
l.max_delta = option_find_float_quiet(options, "max_delta", FLT_MAX); // set 10
|
||||
l.iou_normalizer = option_find_float_quiet(options, "iou_normalizer", 0.75);
|
||||
l.cls_normalizer = option_find_float_quiet(options, "cls_normalizer", 1);
|
||||
char *iou_loss = option_find_str_quiet(options, "iou_loss", "mse"); // "iou");
|
||||
|
@ -534,14 +540,13 @@ layer parse_gaussian_yolo(list *options, size_params params) // Gaussian_YOLOv3
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//assert(l.outputs == params.inputs);
|
||||
|
||||
l.max_delta = option_find_float_quiet(options, "max_delta", FLT_MAX); // set 10
|
||||
char *cpc = option_find_str(options, "counters_per_class", 0);
|
||||
l.classes_multipliers = get_classes_multipliers(cpc, classes);
|
||||
l.classes_multipliers = get_classes_multipliers(cpc, classes, l.max_delta);
|
||||
|
||||
l.label_smooth_eps = option_find_float_quiet(options, "label_smooth_eps", 0.0f);
|
||||
l.scale_x_y = option_find_float_quiet(options, "scale_x_y", 1);
|
||||
l.objectness_smooth = option_find_int_quiet(options, "objectness_smooth", 0);
|
||||
l.max_delta = option_find_float_quiet(options, "max_delta", FLT_MAX); // set 10
|
||||
l.uc_normalizer = option_find_float_quiet(options, "uc_normalizer", 1.0);
|
||||
l.iou_normalizer = option_find_float_quiet(options, "iou_normalizer", 0.75);
|
||||
l.cls_normalizer = option_find_float_quiet(options, "cls_normalizer", 1.0);
|
||||
|
|
|
@ -416,7 +416,9 @@ void forward_yolo_layer(const layer l, network_state state)
|
|||
|
||||
int class_id = state.truth[best_match_t*(4 + 1) + b*l.truths + 4];
|
||||
if (l.map) class_id = l.map[class_id];
|
||||
delta_yolo_class(l.output, l.delta, class_index, class_id, l.classes, l.w*l.h, 0, l.focal_loss, l.label_smooth_eps, l.classes_multipliers);
|
||||
if (class_id < l.classes && class_id >= 0) {
|
||||
delta_yolo_class(l.output, l.delta, class_index, class_id, l.classes, l.w*l.h, 0, l.focal_loss, l.label_smooth_eps, l.classes_multipliers);
|
||||
}
|
||||
}
|
||||
else l.delta[obj_index] = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue