Add 3 preloaded images to CIFAR10 database for tesing purpose
authorChenchi Luo <a0282871@ti.com>
Fri, 17 Apr 2015 16:08:44 +0000 (11:08 -0500)
committerChenchi Luo <a0282871@ti.com>
Fri, 17 Apr 2015 16:08:44 +0000 (11:08 -0500)
src/app/cnn/class/cifar10/appCNNClassCIFAR10Testing.c
src/database/cifar10/0.jpg [new file with mode: 0644]
src/database/cifar10/1.jpg [new file with mode: 0644]
src/database/cifar10/2.jpg [new file with mode: 0644]
src/database/cifar10/label.txt [new file with mode: 0644]

index cf08a13430ea6a75cd8c24b22110a68f2845bfe4..cac970cc308709517dd6ff58ffca6db17b8738c0 100644 (file)
@@ -52,6 +52,9 @@
 
 #define MODEL_PATH       "../../../../database/model/cifar10/databaseModelCIFAR10.m"
 #define DATABASE_PATH    "../../../../database/cifar10"
+#define IMAGE_PATH       "../../../../database/cifar10/%1d.jpg"
+#define LABEL_PATH       "../../../../database/cifar10/label.txt"
+#define IMAGE_NUM        3
 #define TOP_N            1
 #define IMAGE_ROW        32
 #define IMAGE_COL        32
@@ -91,6 +94,11 @@ int appCNNClassCIFAR10Testing()
    int              *label;
    timlUtilImageSet training;
    timlUtilImageSet testing;
+   timlUtilImage    image;
+   char             str[TIML_UTIL_MAX_STR];
+   int              i;
+   FILE             *fp;
+   int              read;
 
    // init
    err         = 0;
@@ -109,9 +117,27 @@ int appCNNClassCIFAR10Testing()
    printf("CNN memory allocation = %.10f MB.\n", (float)mem/1024.0/1024.0);
    printf("CNN parameter #       = %lu.\n", timlCNNGetParamsNum(cnn));
 
-   // read CIFAR10 database
-   printf("2. Read CIFAR10 database\n");
-   timlUtilReadCIFAR10(DATABASE_PATH, &training, &testing);
+//   // read CIFAR10 database
+//   printf("2. Read CIFAR10 database\n");
+//   timlUtilReadCIFAR10(DATABASE_PATH, &training, &testing);
+
+   testing.data  = malloc(sizeof(float)*IMAGE_ROW*IMAGE_COL*IMAGE_CHANNEL*IMAGE_NUM);
+   testing.label = malloc(sizeof(int)*IMAGE_NUM);
+   testing.num   = IMAGE_NUM;
+   // read labels
+   fp = fopen(LABEL_PATH, "rt");
+   for (i = 0; i < IMAGE_NUM; i++) {
+      read = fscanf(fp, "%d", testing.label + i);
+   }
+   fclose(fp);
+
+   // read images
+   for (i = 0; i < IMAGE_NUM; i++) {
+      sprintf(str, IMAGE_PATH, i);
+      image = timlUtilReadJPEG(str);
+      cblas_scopy(dim, image.data, 1, testing.data + i*dim, 1);
+      free(image.data);
+   }
 
    // testing
    printf("3. Start testing\n");
@@ -127,8 +153,8 @@ int appCNNClassCIFAR10Testing()
 
    // cleaning
    printf("4. Clean up\n");
-   free(training.data);
-   free(training.label);
+//   free(training.data);
+//   free(training.label);
    free(testing.data);
    free(testing.label);
    free(label);
diff --git a/src/database/cifar10/0.jpg b/src/database/cifar10/0.jpg
new file mode 100644 (file)
index 0000000..39e51aa
Binary files /dev/null and b/src/database/cifar10/0.jpg differ
diff --git a/src/database/cifar10/1.jpg b/src/database/cifar10/1.jpg
new file mode 100644 (file)
index 0000000..433d879
Binary files /dev/null and b/src/database/cifar10/1.jpg differ
diff --git a/src/database/cifar10/2.jpg b/src/database/cifar10/2.jpg
new file mode 100644 (file)
index 0000000..71ac687
Binary files /dev/null and b/src/database/cifar10/2.jpg differ
diff --git a/src/database/cifar10/label.txt b/src/database/cifar10/label.txt
new file mode 100644 (file)
index 0000000..403ec31
--- /dev/null
@@ -0,0 +1,3 @@
+1
+3
+5