|
|
@ -100,7 +100,7 @@ matrix load_image_paths(char **paths, int n, int w, int h) |
|
|
|
return X; |
|
|
|
return X; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
matrix load_image_augment_paths(char **paths, int n, int min, int max, int size, float angle, float hue, float saturation, float exposure) |
|
|
|
matrix load_image_augment_paths(char **paths, int n, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
matrix X; |
|
|
|
matrix X; |
|
|
@ -110,7 +110,7 @@ matrix load_image_augment_paths(char **paths, int n, int min, int max, int size, |
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < n; ++i){ |
|
|
|
for(i = 0; i < n; ++i){ |
|
|
|
image im = load_image_color(paths[i], 0, 0); |
|
|
|
image im = load_image_color(paths[i], 0, 0); |
|
|
|
image crop = random_augment_image(im, angle, min, max, size); |
|
|
|
image crop = random_augment_image(im, angle, aspect, min, max, size); |
|
|
|
int flip = rand_r(&data_seed)%2; |
|
|
|
int flip = rand_r(&data_seed)%2; |
|
|
|
if (flip) flip_image(crop); |
|
|
|
if (flip) flip_image(crop); |
|
|
|
random_distort_image(crop, hue, saturation, exposure); |
|
|
|
random_distort_image(crop, hue, saturation, exposure); |
|
|
@ -676,15 +676,16 @@ void *load_thread(void *ptr) |
|
|
|
load_args a = *(struct load_args*)ptr; |
|
|
|
load_args a = *(struct load_args*)ptr; |
|
|
|
if(a.exposure == 0) a.exposure = 1; |
|
|
|
if(a.exposure == 0) a.exposure = 1; |
|
|
|
if(a.saturation == 0) a.saturation = 1; |
|
|
|
if(a.saturation == 0) a.saturation = 1; |
|
|
|
|
|
|
|
if(a.aspect == 0) a.aspect = 1; |
|
|
|
|
|
|
|
|
|
|
|
if (a.type == OLD_CLASSIFICATION_DATA){ |
|
|
|
if (a.type == OLD_CLASSIFICATION_DATA){ |
|
|
|
*a.d = load_data(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h); |
|
|
|
*a.d = load_data(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h); |
|
|
|
} else if (a.type == CLASSIFICATION_DATA){ |
|
|
|
} else if (a.type == CLASSIFICATION_DATA){ |
|
|
|
*a.d = load_data_augment(a.paths, a.n, a.m, a.labels, a.classes, a.min, a.max, a.size, a.angle, a.hue, a.saturation, a.exposure); |
|
|
|
*a.d = load_data_augment(a.paths, a.n, a.m, a.labels, a.classes, a.min, a.max, a.size, a.angle, a.aspect, a.hue, a.saturation, a.exposure); |
|
|
|
} else if (a.type == SUPER_DATA){ |
|
|
|
} else if (a.type == SUPER_DATA){ |
|
|
|
*a.d = load_data_super(a.paths, a.n, a.m, a.w, a.h, a.scale); |
|
|
|
*a.d = load_data_super(a.paths, a.n, a.m, a.w, a.h, a.scale); |
|
|
|
} else if (a.type == STUDY_DATA){ |
|
|
|
} else if (a.type == STUDY_DATA){ |
|
|
|
*a.d = load_data_study(a.paths, a.n, a.m, a.labels, a.classes, a.min, a.max, a.size, a.angle, a.hue, a.saturation, a.exposure); |
|
|
|
*a.d = load_data_study(a.paths, a.n, a.m, a.labels, a.classes, a.min, a.max, a.size, a.angle, a.aspect, a.hue, a.saturation, a.exposure); |
|
|
|
} else if (a.type == WRITING_DATA){ |
|
|
|
} else if (a.type == WRITING_DATA){ |
|
|
|
*a.d = load_data_writing(a.paths, a.n, a.m, a.w, a.h, a.out_w, a.out_h); |
|
|
|
*a.d = load_data_writing(a.paths, a.n, a.m, a.w, a.h, a.out_w, a.out_h); |
|
|
|
} else if (a.type == REGION_DATA){ |
|
|
|
} else if (a.type == REGION_DATA){ |
|
|
@ -699,7 +700,7 @@ void *load_thread(void *ptr) |
|
|
|
*(a.im) = load_image_color(a.path, 0, 0); |
|
|
|
*(a.im) = load_image_color(a.path, 0, 0); |
|
|
|
*(a.resized) = resize_image(*(a.im), a.w, a.h); |
|
|
|
*(a.resized) = resize_image(*(a.im), a.w, a.h); |
|
|
|
} else if (a.type == TAG_DATA){ |
|
|
|
} else if (a.type == TAG_DATA){ |
|
|
|
*a.d = load_data_tag(a.paths, a.n, a.m, a.classes, a.min, a.max, a.size, a.angle, a.hue, a.saturation, a.exposure); |
|
|
|
*a.d = load_data_tag(a.paths, a.n, a.m, a.classes, a.min, a.max, a.size, a.angle, a.aspect, a.hue, a.saturation, a.exposure); |
|
|
|
//*a.d = load_data(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h);
|
|
|
|
//*a.d = load_data(a.paths, a.n, a.m, a.labels, a.classes, a.w, a.h);
|
|
|
|
} |
|
|
|
} |
|
|
|
free(ptr); |
|
|
|
free(ptr); |
|
|
@ -741,13 +742,13 @@ data load_data(char **paths, int n, int m, char **labels, int k, int w, int h) |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data load_data_study(char **paths, int n, int m, char **labels, int k, int min, int max, int size, float angle, float hue, float saturation, float exposure) |
|
|
|
data load_data_study(char **paths, int n, int m, char **labels, int k, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
data d = {0}; |
|
|
|
data d = {0}; |
|
|
|
d.indexes = calloc(n, sizeof(int)); |
|
|
|
d.indexes = calloc(n, sizeof(int)); |
|
|
|
if(m) paths = get_random_paths_indexes(paths, n, m, d.indexes); |
|
|
|
if(m) paths = get_random_paths_indexes(paths, n, m, d.indexes); |
|
|
|
d.shallow = 0; |
|
|
|
d.shallow = 0; |
|
|
|
d.X = load_image_augment_paths(paths, n, min, max, size, angle, hue, saturation, exposure); |
|
|
|
d.X = load_image_augment_paths(paths, n, min, max, size, angle, aspect, hue, saturation, exposure); |
|
|
|
d.y = load_labels_paths(paths, n, labels, k); |
|
|
|
d.y = load_labels_paths(paths, n, labels, k); |
|
|
|
if(m) free(paths); |
|
|
|
if(m) free(paths); |
|
|
|
return d; |
|
|
|
return d; |
|
|
@ -783,25 +784,25 @@ data load_data_super(char **paths, int n, int m, int w, int h, int scale) |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data load_data_augment(char **paths, int n, int m, char **labels, int k, int min, int max, int size, float angle, float hue, float saturation, float exposure) |
|
|
|
data load_data_augment(char **paths, int n, int m, char **labels, int k, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(m) paths = get_random_paths(paths, n, m); |
|
|
|
if(m) paths = get_random_paths(paths, n, m); |
|
|
|
data d = {0}; |
|
|
|
data d = {0}; |
|
|
|
d.shallow = 0; |
|
|
|
d.shallow = 0; |
|
|
|
d.X = load_image_augment_paths(paths, n, min, max, size, angle, hue, saturation, exposure); |
|
|
|
d.X = load_image_augment_paths(paths, n, min, max, size, angle, aspect, hue, saturation, exposure); |
|
|
|
d.y = load_labels_paths(paths, n, labels, k); |
|
|
|
d.y = load_labels_paths(paths, n, labels, k); |
|
|
|
if(m) free(paths); |
|
|
|
if(m) free(paths); |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data load_data_tag(char **paths, int n, int m, int k, int min, int max, int size, float angle, float hue, float saturation, float exposure) |
|
|
|
data load_data_tag(char **paths, int n, int m, int k, int min, int max, int size, float angle, float aspect, float hue, float saturation, float exposure) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(m) paths = get_random_paths(paths, n, m); |
|
|
|
if(m) paths = get_random_paths(paths, n, m); |
|
|
|
data d = {0}; |
|
|
|
data d = {0}; |
|
|
|
d.w = size; |
|
|
|
d.w = size; |
|
|
|
d.h = size; |
|
|
|
d.h = size; |
|
|
|
d.shallow = 0; |
|
|
|
d.shallow = 0; |
|
|
|
d.X = load_image_augment_paths(paths, n, min, max, size, angle, hue, saturation, exposure); |
|
|
|
d.X = load_image_augment_paths(paths, n, min, max, size, angle, aspect, hue, saturation, exposure); |
|
|
|
d.y = load_tags_paths(paths, n, k); |
|
|
|
d.y = load_tags_paths(paths, n, k); |
|
|
|
if(m) free(paths); |
|
|
|
if(m) free(paths); |
|
|
|
return d; |
|
|
|
return d; |
|
|
|