Puneet Kohli
2018-05-06 cdd1cb0e8c4fda3671714bb5ad6ba1825cff16d1
src/classifier.c
@@ -6,10 +6,20 @@
#include "assert.h"
#include "classifier.h"
#include "cuda.h"
#ifdef WIN32
#include <time.h>
#include <winsock.h>
#include "gettimeofday.h"
#else
#include <sys/time.h>
#endif
#ifdef OPENCV
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/core/version.hpp"
#ifndef CV_VERSION_EPOCH
#include "opencv2/videoio/videoio_c.h"
#endif
image get_image_from_stream(CvCapture *cap);
#endif
@@ -77,6 +87,7 @@
    args.min = net.min_crop;
    args.max = net.max_crop;
    args.flip = net.flip;
    args.angle = net.angle;
    args.aspect = net.aspect;
    args.exposure = net.exposure;
@@ -183,6 +194,7 @@
   args.min = net.min_crop;
   args.max = net.max_crop;
   args.flip = net.flip;
   args.angle = net.angle;
   args.aspect = net.aspect;
   args.exposure = net.exposure;
@@ -352,11 +364,11 @@
    int *indexes = calloc(topk, sizeof(int));
    for(i = 0; i < m; ++i){
        int class = -1;
        int class_id = -1;
        char *path = paths[i];
        for(j = 0; j < classes; ++j){
            if(strstr(path, labels[j])){
                class = j;
                class_id = j;
                break;
            }
        }
@@ -386,9 +398,9 @@
        free_image(im);
        top_k(pred, classes, topk, indexes);
        free(pred);
        if(indexes[0] == class) avg_acc += 1;
        if(indexes[0] == class_id) avg_acc += 1;
        for(j = 0; j < topk; ++j){
            if(indexes[j] == class) avg_topk += 1;
            if(indexes[j] == class_id) avg_topk += 1;
        }
        printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1));
@@ -425,11 +437,11 @@
    int size = net.w;
    for(i = 0; i < m; ++i){
        int class = -1;
        int class_id = -1;
        char *path = paths[i];
        for(j = 0; j < classes; ++j){
            if(strstr(path, labels[j])){
                class = j;
                class_id = j;
                break;
            }
        }
@@ -446,9 +458,9 @@
        free_image(resized);
        top_k(pred, classes, topk, indexes);
        if(indexes[0] == class) avg_acc += 1;
        if(indexes[0] == class_id) avg_acc += 1;
        for(j = 0; j < topk; ++j){
            if(indexes[j] == class) avg_topk += 1;
            if(indexes[j] == class_id) avg_topk += 1;
        }
        printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1));
@@ -487,11 +499,11 @@
    int *indexes = calloc(topk, sizeof(int));
    for(i = 0; i < m; ++i){
        int class = -1;
        int class_id = -1;
        char *path = paths[i];
        for(j = 0; j < classes; ++j){
            if(strstr(path, labels[j])){
                class = j;
                class_id = j;
                break;
            }
        }
@@ -509,9 +521,9 @@
        free_image(crop);
        top_k(pred, classes, topk, indexes);
        if(indexes[0] == class) avg_acc += 1;
        if(indexes[0] == class_id) avg_acc += 1;
        for(j = 0; j < topk; ++j){
            if(indexes[j] == class) avg_topk += 1;
            if(indexes[j] == class_id) avg_topk += 1;
        }
        printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1));
@@ -549,11 +561,11 @@
    int *indexes = calloc(topk, sizeof(int));
    for(i = 0; i < m; ++i){
        int class = -1;
        int class_id = -1;
        char *path = paths[i];
        for(j = 0; j < classes; ++j){
            if(strstr(path, labels[j])){
                class = j;
                class_id = j;
                break;
            }
        }
@@ -573,9 +585,9 @@
        free_image(im);
        top_k(pred, classes, topk, indexes);
        free(pred);
        if(indexes[0] == class) avg_acc += 1;
        if(indexes[0] == class_id) avg_acc += 1;
        for(j = 0; j < topk; ++j){
            if(indexes[j] == class) avg_topk += 1;
            if(indexes[j] == class_id) avg_topk += 1;
        }
        printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1));
@@ -696,8 +708,9 @@
            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;