pull/6241/head
AlexeyAB 6 years ago
parent 4c26117708
commit 9064755c3b
  1. 24
      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,12 +1382,19 @@ 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;
} }
} }
}
free_data(d2);
free(paths_mix);
}
if (show_imgs) { if (show_imgs) {
int i, j;
for (i = 0; i < d.X.rows; ++i) {
image im = make_empty_image(w, h, 3); image im = make_empty_image(w, h, 3);
im.data = d.X.vals[i]; im.data = d.X.vals[i];
char buff[1000]; char buff[1000];
sprintf(buff, "aug_%d_%s_%d", i, basecfg((char*)paths_mix[i]), random_gen()); sprintf(buff, "aug_%d_%s_%d", i, basecfg((char*)paths[i]), random_gen());
save_image(im, buff); save_image(im, buff);
char buff_string[1000]; char buff_string[1000];
@ -1404,12 +1412,8 @@ data load_data_augment(char **paths, int n, int m, char **labels, int k, tree *h
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