pull/6241/head
AlexeyAB 6 years ago
parent 4c26117708
commit 9064755c3b
  1. 58
      src/data.c
  2. 12
      src/http_stream.cpp

@ -1325,7 +1325,7 @@ data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *h
d.y = load_labels_paths(paths, n, labels, k, hierarchy); d.y = load_labels_paths(paths, n, labels, k, hierarchy);
if(m) free(paths); if(m) free(paths);
if (mixup) { if (mixup && rand_int(0, 1)) {
char **paths_mix = get_random_paths(paths_stored, n, m); char **paths_mix = get_random_paths(paths_stored, n, m);
data d2 = { 0 }; data d2 = { 0 };
d2.shallow = 0; d2.shallow = 0;
@ -1352,9 +1352,10 @@ data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *h
} }
// CutMix // CutMix
else { else {
const float min_offset = 0.2; // 20% const float min = 0.3; // 0.3*0.3 = 9%
const int cut_w = rand_int(w*min_offset, w*(1 - min_offset)); const float max = 0.8; // 0.8*0.8 = 64%
const int cut_h = rand_int(h*min_offset, h*(1 - min_offset)); const int cut_w = rand_int(w*min, w*max);
const int cut_h = rand_int(h*min, h*max);
const int cut_x = rand_int(0, w - cut_w - 1); const int cut_x = rand_int(0, w - cut_w - 1);
const int cut_y = rand_int(0, h - cut_h - 1); const int cut_y = rand_int(0, h - cut_h - 1);
const int left = cut_x; const int left = cut_x;
@ -1381,35 +1382,38 @@ data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *h
d.y.vals[i][j] = d.y.vals[i][j] * beta + d2.y.vals[i][j] * alpha; d.y.vals[i][j] = d.y.vals[i][j] * beta + d2.y.vals[i][j] * alpha;
} }
} }
}
if (show_imgs) { free_data(d2);
image im = make_empty_image(w, h, 3); free(paths_mix);
im.data = d.X.vals[i]; }
char buff[1000];
sprintf(buff, "aug_%d_%s_%d", i, basecfg((char*)paths_mix[i]), random_gen());
save_image(im, buff);
char buff_string[1000]; if (show_imgs) {
sprintf(buff_string, "\n Classes: "); int i, j;
for (j = 0; j < d.y.cols; ++j) { for (i = 0; i < d.X.rows; ++i) {
if (d.y.vals[i][j] > 0) { image im = make_empty_image(w, h, 3);
char buff_tmp[100]; im.data = d.X.vals[i];
sprintf(buff_tmp, " %d (%f), ", j, d.y.vals[i][j]); char buff[1000];
strcat(buff_string, buff_tmp); sprintf(buff, "aug_%d_%s_%d", i, basecfg((char*)paths[i]), random_gen());
} save_image(im, buff);
char buff_string[1000];
sprintf(buff_string, "\n Classes: ");
for (j = 0; j < d.y.cols; ++j) {
if (d.y.vals[i][j] > 0) {
char buff_tmp[100];
sprintf(buff_tmp, " %d (%f), ", j, d.y.vals[i][j]);
strcat(buff_string, buff_tmp);
} }
printf("%s \n", buff_string); }
printf("%s \n", buff_string);
if (show_imgs == 1) { if (show_imgs == 1) {
show_image(im, buff); show_image(im, buff);
wait_until_press_key_cv(); wait_until_press_key_cv();
}
printf("\nYou use flag -show_imgs, so will be saved aug_...jpg images. Click on window and press ESC button \n");
} }
} }
printf("\nYou use flag -show_imgs, so will be saved aug_...jpg images. Click on window and press ESC button \n");
free_data(d2);
free(paths_mix);
} }
return d; return d;

@ -94,9 +94,6 @@ static int close_socket(SOCKET s) {
} }
#endif // _WIN32 #endif // _WIN32
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
class JSON_sender class JSON_sender
{ {
@ -555,6 +552,15 @@ std::string get_system_frame_time_string()
} }
// ---------------------------------------- // ----------------------------------------
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
#ifndef NI_NUMERICHOST
#define NI_NUMERICHOST 0x02
#endif
//#define CPPHTTPLIB_OPENSSL_SUPPORT //#define CPPHTTPLIB_OPENSSL_SUPPORT
#include "httplib.h" #include "httplib.h"

Loading…
Cancel
Save