{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Test de reconnaissance des champignons avec le CNN LeNet5 de Yann Lecun" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import des librairies" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2024-07-26 11:53:42.811603: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n", "2024-07-26 11:53:42.814533: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.\n", "2024-07-26 11:53:42.824745: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", "2024-07-26 11:53:42.842010: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", "2024-07-26 11:53:42.847059: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", "2024-07-26 11:53:42.860107: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", "To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n", "2024-07-26 11:53:43.857673: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "tensorflow version 2.17.0\n", "Num GPUs Available: 0\n" ] } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "import os\n", "import cv2\n", "import pathlib\n", "import itertools\n", "import random\n", "\n", "import PIL\n", "from PIL import Image\n", "\n", "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "\n", "from sklearn import metrics\n", "\n", "import tensorflow as tf\n", "from tensorflow.keras import layers\n", "from tensorflow.keras.models import Sequential, Model\n", "from tensorflow.keras.layers import Dense, Activation, Input\n", "from tensorflow.keras.layers import Dropout\n", "from tensorflow.keras.layers import Flatten\n", "from tensorflow.keras.layers import Conv2D\n", "from tensorflow.keras.layers import MaxPooling2D\n", "from tensorflow.keras.utils import to_categorical\n", "\n", "print(\"tensorflow version\",tf.__version__)\n", "print(\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Récupération des datas (prêtes et augmentée)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "mo_db_path=\"../../data/LAYER2/MO/\"\n", "names_csv_path=\"../../data/LAYER2/names.csv\"\n", "\n", "data_dir = pathlib.Path(mo_db_path)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | name | \n", "
---|---|
id | \n", "\n", " |
373 | \n", "Amanita muscaria | \n", "
50164 | \n", "Baorangia bicolor | \n", "
15162 | \n", "Bolbitius titubans | \n", "
42 | \n", "Trametes versicolor | \n", "
330 | \n", "Cantharellus cinnabarinus | \n", "
1174 | \n", "Ceratiomyxa fruticulosa | \n", "
382 | \n", "Amanita bisporigera | \n", "
344 | \n", "Boletus edulis | \n", "
63454 | \n", "Boletus rex-veris | \n", "
29997 | \n", "Morchella importuna | \n", "
1540 | \n", "Boletinellus merulioides | \n", "
362 | \n", "Amanita velosa | \n", "
39842 | \n", "Amanita augusta | \n", "
2749 | \n", "Lactarius indigo | \n", "