From 9064755c3bd67ba775f46d859040c13b5fa6eff2 Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Mon, 2 Dec 2019 03:11:22 +0300 Subject: [PATCH] Minor fix --- src/data.c | 58 ++++++++++++++++++++++++--------------------- src/http_stream.cpp | 12 +++++++--- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/data.c b/src/data.c index 6b7e039b..4323b84d 100644 --- a/src/data.c +++ b/src/data.c @@ -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); if(m) free(paths); - if (mixup) { + if (mixup && rand_int(0, 1)) { char **paths_mix = get_random_paths(paths_stored, n, m); data d2 = { 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 else { - const float min_offset = 0.2; // 20% - const int cut_w = rand_int(w*min_offset, w*(1 - min_offset)); - const int cut_h = rand_int(h*min_offset, h*(1 - min_offset)); + const float min = 0.3; // 0.3*0.3 = 9% + const float max = 0.8; // 0.8*0.8 = 64% + 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_y = rand_int(0, h - cut_h - 1); 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; } } + } - if (show_imgs) { - image im = make_empty_image(w, h, 3); - 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); + free_data(d2); + free(paths_mix); + } - 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); - } + if (show_imgs) { + int i, j; + for (i = 0; i < d.X.rows; ++i) { + image im = make_empty_image(w, h, 3); + im.data = d.X.vals[i]; + char buff[1000]; + 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) { - show_image(im, buff); - 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"); + if (show_imgs == 1) { + show_image(im, buff); + wait_until_press_key_cv(); } } - - free_data(d2); - free(paths_mix); + printf("\nYou use flag -show_imgs, so will be saved aug_...jpg images. Click on window and press ESC button \n"); } return d; diff --git a/src/http_stream.cpp b/src/http_stream.cpp index f9dc7790..45f629b2 100644 --- a/src/http_stream.cpp +++ b/src/http_stream.cpp @@ -94,9 +94,6 @@ static int close_socket(SOCKET s) { } #endif // _WIN32 -#ifndef NI_MAXHOST -#define NI_MAXHOST 1025 -#endif 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 #include "httplib.h"