Fixed classifier for AlexNet and Resnet50
| | |
| | | strtok(input, "\n"); |
| | | } |
| | | image im = load_image_color(input, 0, 0); |
| | | image r = resize_min(im, size); |
| | | resize_network(&net, r.w, r.h); |
| | | image r = letterbox_image(im, net.w, net.h); |
| | | //image r = resize_min(im, size); |
| | | //resize_network(&net, r.w, r.h); |
| | | printf("%d %d\n", r.w, r.h); |
| | | |
| | | float *X = r.data; |
| | |
| | | #endif |
| | | } |
| | | |
| | | void fill_image(image m, float s) |
| | | { |
| | | int i; |
| | | for (i = 0; i < m.h*m.w*m.c; ++i) m.data[i] = s; |
| | | } |
| | | |
| | | void letterbox_image_into(image im, int w, int h, image boxed) |
| | | { |
| | | int new_w = im.w; |
| | | int new_h = im.h; |
| | | if (((float)w / im.w) < ((float)h / im.h)) { |
| | | new_w = w; |
| | | new_h = (im.h * w) / im.w; |
| | | } |
| | | else { |
| | | new_h = h; |
| | | new_w = (im.w * h) / im.h; |
| | | } |
| | | image resized = resize_image(im, new_w, new_h); |
| | | embed_image(resized, boxed, (w - new_w) / 2, (h - new_h) / 2); |
| | | free_image(resized); |
| | | } |
| | | |
| | | image letterbox_image(image im, int w, int h) |
| | | { |
| | | int new_w = im.w; |
| | | int new_h = im.h; |
| | | if (((float)w / im.w) < ((float)h / im.h)) { |
| | | new_w = w; |
| | | new_h = (im.h * w) / im.w; |
| | | } |
| | | else { |
| | | new_h = h; |
| | | new_w = (im.w * h) / im.h; |
| | | } |
| | | image resized = resize_image(im, new_w, new_h); |
| | | image boxed = make_image(w, h, im.c); |
| | | fill_image(boxed, .5); |
| | | //int i; |
| | | //for(i = 0; i < boxed.w*boxed.h*boxed.c; ++i) boxed.data[i] = 0; |
| | | embed_image(resized, boxed, (w - new_w) / 2, (h - new_h) / 2); |
| | | free_image(resized); |
| | | return boxed; |
| | | } |
| | | |
| | | image resize_max(image im, int max) |
| | | { |
| | | int w = im.w; |
| | |
| | | |
| | | #ifndef CV_VERSION_EPOCH |
| | | image out = load_image_stb(filename, c); // OpenCV 3.x |
| | | //image out = load_image_cv(filename, c); |
| | | #else |
| | | image out = load_image_cv(filename, c); // OpenCV 2.4.x |
| | | #endif |
| | |
| | | image random_augment_image(image im, float angle, float aspect, int low, int high, int size); |
| | | void random_distort_image(image im, float hue, float saturation, float exposure); |
| | | image resize_image(image im, int w, int h); |
| | | void fill_image(image m, float s); |
| | | void letterbox_image_into(image im, int w, int h, image boxed); |
| | | image letterbox_image(image im, int w, int h); |
| | | image resize_min(image im, int min); |
| | | image resize_max(image im, int max); |
| | | void translate_image(image m, float s); |
| | |
| | | }else if(l.type == COST){ |
| | | resize_cost_layer(&l, inputs); |
| | | }else{ |
| | | fprintf(stderr, "Resizing type %d \n", (int)l.type); |
| | | error("Cannot resize this type of layer"); |
| | | } |
| | | if(l.workspace_size > workspace_size) workspace_size = l.workspace_size; |