mirror of https://github.com/AlexeyAB/darknet.git
Added blur=1 for Classifier training if OPENCV=1 (removes textures like in stylized-ImageNet)
This commit is contained in:
parent
efc5478a23
commit
142fcdeb1e
|
@ -12,6 +12,7 @@ momentum=0.9
|
|||
decay=0.0005
|
||||
max_crop=256
|
||||
#mixup=4
|
||||
blur=1
|
||||
cutmix=1
|
||||
mosaic=1
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ momentum=0.9
|
|||
decay=0.0005
|
||||
max_crop=256
|
||||
#mixup=4
|
||||
blur=1
|
||||
cutmix=1
|
||||
mosaic=1
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ void train_classifier(char *datacfg, char *cfgfile, char *weightfile, int *gpus,
|
|||
args.min = net.min_crop;
|
||||
args.max = net.max_crop;
|
||||
args.flip = net.flip;
|
||||
args.blur = net.blur;
|
||||
args.angle = net.angle;
|
||||
args.aspect = net.aspect;
|
||||
args.exposure = net.exposure;
|
||||
|
|
26
src/data.c
26
src/data.c
|
@ -1289,7 +1289,7 @@ void *load_thread(void *ptr)
|
|||
if (a.type == OLD_CLASSIFICATION_DATA){
|
||||
*a.d = load_data_old(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h);
|
||||
} else if (a.type == CLASSIFICATION_DATA){
|
||||
*a.d = load_data_augment(a.paths, a.n, a.m, a.labels, a.classes, a.hierarchy, a.flip, a.min, a.max, a.w, a.h, a.angle, a.aspect, a.hue, a.saturation, a.exposure, a.mixup, a.show_imgs);
|
||||
*a.d = load_data_augment(a.paths, a.n, a.m, a.labels, a.classes, a.hierarchy, a.flip, a.min, a.max, a.w, a.h, a.angle, a.aspect, a.hue, a.saturation, a.exposure, a.mixup, a.blur, a.show_imgs);
|
||||
} else if (a.type == SUPER_DATA){
|
||||
*a.d = load_data_super(a.paths, a.n, a.m, a.w, a.h, a.scale);
|
||||
} else if (a.type == WRITING_DATA){
|
||||
|
@ -1434,7 +1434,7 @@ data load_data_super(char **paths, int n, int m, int w, int h, int scale)
|
|||
return d;
|
||||
}
|
||||
|
||||
data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *hierarchy, int use_flip, int min, int max, int w, int h, float angle, float aspect, float hue, float saturation, float exposure, int mixup, int show_imgs)
|
||||
data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *hierarchy, int use_flip, int min, int max, int w, int h, float angle, float aspect, float hue, float saturation, float exposure, int mixup, int use_blur, int show_imgs)
|
||||
{
|
||||
char **paths_stored = paths;
|
||||
if(m) paths = get_random_paths(paths, n, m);
|
||||
|
@ -1557,6 +1557,28 @@ data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *h
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef OPENCV
|
||||
if (use_blur) {
|
||||
int i;
|
||||
for (i = 0; i < d.X.rows; ++i) {
|
||||
if (random_gen() % 2) {
|
||||
image im = make_empty_image(w, h, 3);
|
||||
im.data = d.X.vals[i];
|
||||
int ksize = use_blur;
|
||||
if (use_blur == 1) ksize = 17;
|
||||
image blurred = blur_image(im, ksize);
|
||||
free_image(im);
|
||||
d.X.vals[i] = blurred.data;
|
||||
//if (i == 0) {
|
||||
// show_image(im, "Not blurred");
|
||||
// show_image(blurred, "blurred");
|
||||
// wait_until_press_key_cv();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // OPENCV
|
||||
|
||||
if (show_imgs) {
|
||||
int i, j;
|
||||
for (i = 0; i < d.X.rows; ++i) {
|
||||
|
|
|
@ -91,7 +91,7 @@ data load_data_detection(int n, char **paths, int m, int w, int h, int c, int bo
|
|||
data load_data_tag(char **paths, int n, int m, int k, int use_flip, int min, int max, int w, int h, float angle, float aspect, float hue, float saturation, float exposure);
|
||||
matrix load_image_augment_paths(char **paths, int n, int use_flip, int min, int max, int w, int h, float angle, float aspect, float hue, float saturation, float exposure);
|
||||
data load_data_super(char **paths, int n, int m, int w, int h, int scale);
|
||||
data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *hierarchy, int use_flip, int min, int max, int w, int h, float angle, float aspect, float hue, float saturation, float exposure, int mixup, int show_imgs);
|
||||
data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *hierarchy, int use_flip, int min, int max, int w, int h, float angle, float aspect, float hue, float saturation, float exposure, int mixup, int use_blur, int show_imgs);
|
||||
data load_go(char *filename);
|
||||
|
||||
box_label *read_boxes(char *filename, int *n);
|
||||
|
|
|
@ -1258,6 +1258,16 @@ void blend_images_cv(image new_img, float alpha, image old_img, float beta)
|
|||
cv::addWeighted(new_mat, alpha, old_mat, beta, 0.0, new_mat);
|
||||
}
|
||||
|
||||
// bilateralFilter bluring
|
||||
image blur_image(image src_img, int ksize)
|
||||
{
|
||||
cv::Mat src = image_to_mat(src_img);
|
||||
cv::Mat dst;
|
||||
cv::bilateralFilter(src, dst, ksize, 75, 75);
|
||||
image dst_img = mat_to_image(dst);
|
||||
return dst_img;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Show Anchors
|
||||
// ====================================================================
|
||||
|
|
|
@ -101,6 +101,9 @@ image image_data_augmentation(mat_cv* mat, int w, int h,
|
|||
// blend two images with (alpha and beta)
|
||||
void blend_images_cv(image new_img, float alpha, image old_img, float beta);
|
||||
|
||||
// bilateralFilter bluring
|
||||
image blur_image(image src_img, int ksize);
|
||||
|
||||
// Show Anchors
|
||||
void show_acnhors(int number_of_boxes, int num_of_clusters, float *rel_width_height_array, model anchors_data, int width, int height);
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ void backward_network_gpu(network net, network_state state)
|
|||
|
||||
if (i != 0) {
|
||||
layer prev = net.layers[i - 1];
|
||||
if (net.optimized_memory && state.delta && !prev.keep_delta_gpu && prev.delta_gpu != l.delta_gpu) {
|
||||
simple_copy_ongpu(prev.outputs*prev.batch, state.delta, prev.delta_gpu);
|
||||
if (net.optimized_memory && state.delta && !prev.keep_delta_gpu) {
|
||||
if (prev.delta_gpu != state.delta) simple_copy_ongpu(prev.outputs*prev.batch, state.delta, prev.delta_gpu);
|
||||
fill_ongpu(prev.outputs*prev.batch, 0, net.state_delta_gpu, 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue