EmotionDetectionCV/modelTrainer.ipynb

2 lines
332 KiB
Plaintext
Raw Normal View History

2023-01-07 16:16:30 +01:00
{"cells":[{"cell_type":"code","execution_count":1,"metadata":{"executionInfo":{"elapsed":3876,"status":"ok","timestamp":1673089178773,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"jodJ-FDfw0dd"},"outputs":[],"source":["! pip install -q kaggle"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"bViTodYiyPQ_"},"outputs":[],"source":["from google.colab import files\n","# run and paste your kaggle.json file (api key)\n","files.upload()"]},{"cell_type":"code","execution_count":3,"metadata":{"executionInfo":{"elapsed":219,"status":"ok","timestamp":1673089184790,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"e6GaJCkXy66h"},"outputs":[],"source":["! mkdir ~/.kaggle"]},{"cell_type":"code","execution_count":4,"metadata":{"executionInfo":{"elapsed":3,"status":"ok","timestamp":1673089186076,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"-JAzcY64y9Z-"},"outputs":[],"source":["! cp kaggle.json ~/.kaggle/"]},{"cell_type":"code","execution_count":5,"metadata":{"executionInfo":{"elapsed":746,"status":"ok","timestamp":1673089188353,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"yj9E_8Xmy_df"},"outputs":[],"source":["! chmod 600 ~/.kaggle/kaggle.json"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":792,"status":"ok","timestamp":1673089190093,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"Zn39dv15zBFn","outputId":"a96e4935-ef80-40e3-f037-7b6ef76c1885"},"outputs":[],"source":["! kaggle datasets list"]},{"cell_type":"code","execution_count":7,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":1404,"status":"ok","timestamp":1673089333444,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"OAz0Umle4xf5","outputId":"89acb158-bdd2-4a4a-fcff-035915a93699"},"outputs":[{"name":"stdout","output_type":"stream","text":["Downloading face-expression-recognition-dataset.zip to /content\n"," 93% 112M/121M [00:00<00:00, 217MB/s] \n","100% 121M/121M [00:00<00:00, 217MB/s]\n"]}],"source":["! kaggle datasets download -d jonathanoheix/face-expression-recognition-dataset"]},{"cell_type":"markdown","metadata":{"id":"0yYBm4b55ZBm"},"source":["## Load Data"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":32292,"status":"ok","timestamp":1673089492816,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"s26DWJCk5vq8","outputId":"584f88c0-e24b-4847-ff1a-4a7ff262992c"},"outputs":[],"source":["# importing required modules\n","from zipfile import ZipFile\n"," \n","# specifying the zip file name\n","file_name = \"/content/face-expression-recognition-dataset.zip\"\n"," \n","# opening the zip file in READ mode\n","with ZipFile(file_name, 'r') as zip:\n"," # printing all the contents of the zip file\n"," zip.printdir()\n"," \n"," # extracting all the files\n"," print('Extracting all the files now...')\n"," zip.extractall()\n"," print('Done!')"]},{"cell_type":"code","execution_count":65,"metadata":{"executionInfo":{"elapsed":200,"status":"ok","timestamp":1673097954289,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"j23l4luA5blT"},"outputs":[],"source":["import numpy as np # linear algebra\n","import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","import os\n","import matplotlib.pyplot as plt\n","import seaborn as sns"]},{"cell_type":"code","execution_count":68,"metadata":{"executionInfo":{"elapsed":308,"status":"ok","timestamp":1673098013758,"user":{"displayName":"Mikołaj Krzymiński","userId":"01535337980860424008"},"user_tz":-60},"id":"v35PuWG57DUd"},"outputs":[],"source":["from tensorflow.keras.utils import load_img, img_to_