Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix too many or too few labels error on Linux/Mac/Windows when trainning #6676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,18 @@ data load_data_captcha_encode(char **paths, int n, int m, int w, int h)
void fill_truth(char *path, char **labels, int k, float *truth)
{
int i;
char *filename = "";
for(i = strlen(path) - 1; i >= 0; --i) {
if (path[i] == '/' || path[i] == '\\') {
filename = (char*)malloc(strlen(path + i) + 1);
strcpy(filename, path + i + 1);
break;
}
}
memset(truth, 0, k*sizeof(float));
int count = 0;
for(i = 0; i < k; ++i){
if(strstr(path, labels[i])){
if(strstr(filename, labels[i])){
truth[i] = 1;
++count;
}
Expand All @@ -548,10 +556,18 @@ void fill_truth(char *path, char **labels, int k, float *truth)
void fill_truth_smooth(char *path, char **labels, int k, float *truth, float label_smooth_eps)
{
int i;
char *filename = "";
for(i = strlen(path) - 1; i >= 0; --i) {
if (path[i] == '/' || path[i] == '\\') {
filename = (char*)malloc(strlen(path + i) + 1);
strcpy(filename, path + i + 1);
break;
}
}
memset(truth, 0, k * sizeof(float));
int count = 0;
for (i = 0; i < k; ++i) {
if (strstr(path, labels[i])) {
if (strstr(filename, labels[i])) {
truth[i] = (1 - label_smooth_eps);
++count;
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,10 @@ layer parse_shortcut(list *options, size_params params, network net)

for (i = 0; i < n; ++i) {
int index = layers[i];
assert(params.w == net.layers[index].out_w && params.h == net.layers[index].out_h);
// assert(params.w == net.layers[index].out_w && params.h == net.layers[index].out_h);

if (params.w != net.layers[index].out_w || params.h != net.layers[index].out_h || params.c != net.layers[index].out_c)
fprintf(stderr, " (%4d x%4d x%4d) + (%4d x%4d x%4d) \n",
fprintf(stderr, "Downsample here: (%d x %d x %d) + (%d x %d x %d) \n",
params.w, params.h, params.c, net.layers[index].out_w, net.layers[index].out_h, params.net.layers[index].out_c);
}

Expand Down