From 4e1cf3e627bdd110be2a7641b1d0464d2a16a059 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Mon, 5 Jun 2023 21:06:21 +0200 Subject: [PATCH] cnn: Remove STORE_IMAGES_TO_RAM option --- src/cnn/include/config.h | 7 ------- src/cnn/include/jpeg.h | 2 +- src/cnn/jpeg.c | 15 --------------- test/cnn_jpeg.c | 15 --------------- 4 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/cnn/include/config.h b/src/cnn/include/config.h index df9d89e..349e1be 100644 --- a/src/cnn/include/config.h +++ b/src/cnn/include/config.h @@ -42,13 +42,6 @@ //** Paramètres d'optimisation -//* Paramètre d'optimisation pour un dataset Jpeg -// keep images in ram e.g re-read and decompress each time -// Enabling this will lead to a large amount of ram used while economizing not that -// much computing power -// Note: 50States10K dataset is 90Go once decompressed, use with caution -//#define STORE_IMAGES_TO_RAM - //* Optimisation de libération de la mémoire pour de larges réseaux // En utilisant CUDA, de larges réseaux créés dans src/common/memory_management.cu // peuvent prendre jusqu'à plusieurs heures pour être libérés diff --git a/src/cnn/include/jpeg.h b/src/cnn/include/jpeg.h index 166215b..c3e7149 100644 --- a/src/cnn/include/jpeg.h +++ b/src/cnn/include/jpeg.h @@ -24,7 +24,7 @@ typedef struct jpegDataset { unsigned int height; // Hauteur des images unsigned int* labels; // Labels - unsigned char** images; // Images en cache, vaut NULL si STORE_IMAGES_TO_RAM n'est pas défini + unsigned char** images; // Images en cache char** fileNames; // Noms de fichiers } jpegDataset; diff --git a/src/cnn/jpeg.c b/src/cnn/jpeg.c index 9e21a76..e3b4b00 100644 --- a/src/cnn/jpeg.c +++ b/src/cnn/jpeg.c @@ -157,19 +157,7 @@ jpegDataset* loadJpegDataset(char* folderPath) { dataset->images = (unsigned char**)malloc(sizeof(unsigned char*)*dataset->numImages); for (int i=0; i < (int)dataset->numImages; i++) { dataset->images[i] = NULL; - #ifdef STORE_IMAGES_TO_RAM - if (i%1000 == 0) { - printf("[%d/%d] Chargement des images\r\n", i, dataset->numImages); - fflush(stdout); - } - image = loadJpegImageFile(dataset->fileNames[i]); - dataset->images[i] = image->lpData; - free(image); - #endif } - #ifdef STORE_IMAGES_TO_RAM - printf("Chargement des images terminé \n"); - #endif // Lecture des caractéristiques des images image = loadJpegImageFile(dataset->fileNames[0]); @@ -245,9 +233,6 @@ void addFilenamesToArray(char* path, char** array, int* index) { void free_dataset(jpegDataset* dataset) { for (int i=0; i < (int)dataset->numImages; i++) { free(dataset->fileNames[i]); - #ifdef STORE_IMAGES_TO_RAM - free(dataset->images[i]); - #endif } free(dataset->fileNames); free(dataset->labels); diff --git a/test/cnn_jpeg.c b/test/cnn_jpeg.c index a05f7df..28619c7 100644 --- a/test/cnn_jpeg.c +++ b/test/cnn_jpeg.c @@ -19,12 +19,6 @@ int main(int argc, char* argv[]) { printf("Nombre de catégories: %d\n", dataset->numCategories); printf("Nombre d'images: %d\n", dataset->numImages); printf("Taille des images: %dx%d\n", dataset->width, dataset->height); - #ifdef STORE_IMAGES_TO_RAM - if (!dataset->images) { - printf_error("Aucune image n'a été chargée\n"); - return 1; - } - #endif // Calcul du temps de chargement des images une à une double start_time, end_time; @@ -47,15 +41,6 @@ int main(int argc, char* argv[]) { printf("%d\n", i); return 1; } - #ifdef STORE_IMAGES_TO_RAM - if (!dataset->images[i]) { - printf_error("Image non chargée à l'index "); - printf("%d\n", i); - printf_error("Nom du fichier: "); - printf("%s\n", dataset->fileNames[i]); - return 1; - } - #endif } free_dataset(dataset);