2021-12-04 18:01:55 +01:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 297,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "b026b65f",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import tensorflow as tf\n",
|
|
|
|
"from tensorflow.keras import datasets\n",
|
|
|
|
"from tensorflow.keras.models import Sequential\n",
|
|
|
|
"from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, MaxPooling2D\n",
|
|
|
|
"import os\n",
|
|
|
|
"from sklearn.model_selection import train_test_split\n",
|
|
|
|
"import cv2\n",
|
2021-12-04 19:42:54 +01:00
|
|
|
"import numpy as np\n",
|
|
|
|
"import matplotlib.pyplot as plt"
|
2021-12-04 18:01:55 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 298,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "f4b3c889",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def preprocess(img):\n",
|
|
|
|
" scale_percent = 10\n",
|
|
|
|
" width = int(img.shape[1] * scale_percent / 100)\n",
|
|
|
|
" height = int(img.shape[0] * scale_percent / 100)\n",
|
|
|
|
" dim = (width, height)\n",
|
|
|
|
" resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)\n",
|
|
|
|
" return resized\n",
|
|
|
|
"\n",
|
|
|
|
"def readData(data_links):\n",
|
|
|
|
" x, y = [], []\n",
|
|
|
|
" for link in data_links:\n",
|
|
|
|
" img = cv2.imread(link, cv2.IMREAD_COLOR)\n",
|
|
|
|
" img = preprocess(img)\n",
|
|
|
|
" label = link.split(\"/\")[1].split('_')[1]\n",
|
|
|
|
" new_label = 4\n",
|
|
|
|
" \n",
|
|
|
|
" if label == '3':\n",
|
|
|
|
" new_label = 0\n",
|
|
|
|
" elif label == '5':\n",
|
|
|
|
" new_label = 1\n",
|
|
|
|
" elif label == '8':\n",
|
|
|
|
" new_label = 2\n",
|
|
|
|
" \n",
|
|
|
|
" x.append(img)\n",
|
|
|
|
" y.append(new_label)\n",
|
|
|
|
"\n",
|
|
|
|
" return x, y\n",
|
|
|
|
"\n",
|
|
|
|
"data_links = os.listdir(\"data/\")\n",
|
|
|
|
"data_links = [\"data/\" + x for x in data_links]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 299,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "b9df2aa9",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"x, y = readData(data_links)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 300,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "a8977fc6",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
2021-12-04 19:42:54 +01:00
|
|
|
"X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=42)"
|
2021-12-04 18:01:55 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 301,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "97e8bc4e",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"(60, 80, 3)"
|
|
|
|
]
|
|
|
|
},
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 301,
|
2021-12-04 18:01:55 +01:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"X_train[0].shape"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 302,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "2d3f1e5e",
|
|
|
|
"metadata": {},
|
2021-12-04 19:42:54 +01:00
|
|
|
"outputs": [],
|
2021-12-04 18:01:55 +01:00
|
|
|
"source": [
|
|
|
|
"X_train = np.array([i / 255.0 for i in X_train], dtype=np.float64)\n",
|
|
|
|
"X_test = np.array([i / 255.0 for i in X_test], dtype=np.float64)\n",
|
|
|
|
"y_train = np.array(y_train, dtype=np.int64)\n",
|
2021-12-04 19:42:54 +01:00
|
|
|
"y_test = np.array(y_test, dtype=np.int64)"
|
2021-12-04 18:01:55 +01:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 369,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "2a10ce01",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"model = Sequential()\n",
|
|
|
|
"model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(60, 80, 3)))\n",
|
|
|
|
"model.add(MaxPooling2D((2, 2)))\n",
|
|
|
|
"model.add(Conv2D(64, (3, 3), activation='relu'))\n",
|
2021-12-04 19:42:54 +01:00
|
|
|
"\n",
|
|
|
|
"model.add(MaxPooling2D((2, 2)))\n",
|
|
|
|
"model.add(Conv2D(64, (3, 3), activation='relu'))\n",
|
|
|
|
"\n",
|
2021-12-04 18:01:55 +01:00
|
|
|
"model.add(MaxPooling2D((2, 2)))\n",
|
|
|
|
"model.add(Conv2D(64, (3, 3), activation='relu'))\n",
|
|
|
|
"model.add(Flatten())\n",
|
2021-12-04 19:42:54 +01:00
|
|
|
"model.add(Dense(256, activation='relu'))\n",
|
2021-12-04 18:01:55 +01:00
|
|
|
"model.add(Dense(3, activation='sigmoid'))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 370,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "67f6cef9",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"model.compile(optimizer='adam',\n",
|
|
|
|
" loss=tf.keras.losses.SparseCategoricalCrossentropy(),\n",
|
|
|
|
" metrics=['accuracy'])\n",
|
|
|
|
"\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 371,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "802da4db",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-12-04 19:42:54 +01:00
|
|
|
"Epoch 1/20\n",
|
|
|
|
"20/20 [==============================] - 2s 70ms/step - loss: 1.0857 - accuracy: 0.3730 - val_loss: 1.0336 - val_accuracy: 0.4926\n",
|
|
|
|
"Epoch 2/20\n",
|
|
|
|
"20/20 [==============================] - 1s 64ms/step - loss: 0.9725 - accuracy: 0.5127 - val_loss: 0.8676 - val_accuracy: 0.6037\n",
|
|
|
|
"Epoch 3/20\n",
|
|
|
|
"20/20 [==============================] - 1s 65ms/step - loss: 0.8294 - accuracy: 0.6524 - val_loss: 0.7766 - val_accuracy: 0.6852\n",
|
|
|
|
"Epoch 4/20\n",
|
|
|
|
"20/20 [==============================] - 1s 65ms/step - loss: 0.8491 - accuracy: 0.6476 - val_loss: 0.7487 - val_accuracy: 0.6815\n",
|
|
|
|
"Epoch 5/20\n",
|
|
|
|
"20/20 [==============================] - 1s 66ms/step - loss: 0.7602 - accuracy: 0.6667 - val_loss: 0.8408 - val_accuracy: 0.5741\n",
|
|
|
|
"Epoch 6/20\n",
|
|
|
|
"20/20 [==============================] - 1s 66ms/step - loss: 0.7095 - accuracy: 0.7048 - val_loss: 0.6505 - val_accuracy: 0.7296\n",
|
|
|
|
"Epoch 7/20\n",
|
|
|
|
"20/20 [==============================] - 1s 65ms/step - loss: 0.6341 - accuracy: 0.7349 - val_loss: 0.5629 - val_accuracy: 0.7852\n",
|
|
|
|
"Epoch 8/20\n",
|
|
|
|
"20/20 [==============================] - 1s 68ms/step - loss: 0.5052 - accuracy: 0.7921 - val_loss: 0.4398 - val_accuracy: 0.8444\n",
|
|
|
|
"Epoch 9/20\n",
|
|
|
|
"20/20 [==============================] - 1s 70ms/step - loss: 0.3686 - accuracy: 0.8508 - val_loss: 0.3397 - val_accuracy: 0.8593\n",
|
|
|
|
"Epoch 10/20\n",
|
|
|
|
"20/20 [==============================] - 1s 70ms/step - loss: 0.2249 - accuracy: 0.9317 - val_loss: 0.2998 - val_accuracy: 0.8889\n",
|
|
|
|
"Epoch 11/20\n",
|
|
|
|
"20/20 [==============================] - 1s 70ms/step - loss: 0.4271 - accuracy: 0.8365 - val_loss: 0.4476 - val_accuracy: 0.8296\n",
|
|
|
|
"Epoch 12/20\n",
|
|
|
|
"20/20 [==============================] - 1s 67ms/step - loss: 0.2457 - accuracy: 0.9270 - val_loss: 0.2269 - val_accuracy: 0.9074\n",
|
|
|
|
"Epoch 13/20\n",
|
|
|
|
"20/20 [==============================] - 1s 67ms/step - loss: 0.1181 - accuracy: 0.9635 - val_loss: 0.1664 - val_accuracy: 0.9407\n",
|
|
|
|
"Epoch 14/20\n",
|
|
|
|
"20/20 [==============================] - 1s 68ms/step - loss: 0.0965 - accuracy: 0.9714 - val_loss: 0.1522 - val_accuracy: 0.9444\n",
|
|
|
|
"Epoch 15/20\n",
|
|
|
|
"20/20 [==============================] - 1s 70ms/step - loss: 0.0577 - accuracy: 0.9810 - val_loss: 0.1595 - val_accuracy: 0.9444\n",
|
|
|
|
"Epoch 16/20\n",
|
|
|
|
"20/20 [==============================] - 1s 68ms/step - loss: 0.1496 - accuracy: 0.9444 - val_loss: 0.3178 - val_accuracy: 0.8963\n",
|
|
|
|
"Epoch 17/20\n",
|
|
|
|
"20/20 [==============================] - 1s 66ms/step - loss: 0.0731 - accuracy: 0.9794 - val_loss: 0.0890 - val_accuracy: 0.9704\n",
|
|
|
|
"Epoch 18/20\n",
|
|
|
|
"20/20 [==============================] - 1s 66ms/step - loss: 0.0253 - accuracy: 0.9937 - val_loss: 0.0744 - val_accuracy: 0.9704\n",
|
|
|
|
"Epoch 19/20\n",
|
|
|
|
"20/20 [==============================] - 1s 65ms/step - loss: 0.0138 - accuracy: 0.9984 - val_loss: 0.0656 - val_accuracy: 0.9778\n",
|
|
|
|
"Epoch 20/20\n",
|
|
|
|
"20/20 [==============================] - 1s 65ms/step - loss: 0.0092 - accuracy: 0.9984 - val_loss: 0.0616 - val_accuracy: 0.9741\n"
|
2021-12-04 18:01:55 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2021-12-04 19:42:54 +01:00
|
|
|
"history = model.fit(X_train, y_train, epochs=20, \n",
|
2021-12-04 18:01:55 +01:00
|
|
|
" validation_data=(X_test, y_test))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-12-04 19:42:54 +01:00
|
|
|
"execution_count": 372,
|
2021-12-04 18:01:55 +01:00
|
|
|
"id": "a27e69ff",
|
|
|
|
"metadata": {},
|
2021-12-04 19:42:54 +01:00
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"9/9 - 0s - loss: 0.0616 - accuracy: 0.9741 - 153ms/epoch - 17ms/step\n",
|
|
|
|
"0.06160588562488556\n",
|
|
|
|
"0.9740740656852722\n"
|
|
|
|
]
|
|
|
|
},
|
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FiNMSthsuekrMBB0kiEKKByy8qZu6H0ayPTeXF6f2ZOSTcsQ2LiyDn9IXFzkoeybZ1yZCbVnfBDrwRprxVrU2uH9YBNwUPf72HoZ2CeffWKAIqmztYzgaqTRKBEA1YXqGRBDbEGUlgRlQFSaAg2/iATDn0xwd9bmr5dsrdKMUQ0AZadIDwoUb5Y/82xsOjgm/hjjj8E2xZAOHDYdBN1dp09tAODO0cTPsgn8pnOUuMgdhf4LInoZmdawfCLkkEQjRQeYXF3PbBNjYdTeM/10YyfXCY/YY5KbDkWji1B9r2g8Awo3Ba6br3/m2Mn36twM2k6SQ7XwJnDsDKvxkF29r2q9bmXexdFC5r7fPgEwxD5tYsxiZKEoEQDVBuoYXb3o9my7E0/jszkqkDK0gC6cfg42mQlQzXfQo9rqzfQEtzc4fp78I7F8MXN8O83+q2cufJGDjyM4z7p5wNVJPcNSREA3OuwMKcxdvYciyNV2YNqDgJJO+Cd6+AvLNwy7fOTQLn+YfAtYvh7An45m6j5n5d+e0F8AmCofPqbp9NhCQCIRxwrsDCI1/vJvFsrtPjmLN4G9uOp/Pq7IFMGdDefsOja2HxVeDuBX/6yejrdxUdR8DlT8GB72Dz/9XNPk9uhyM/GTN4lZ4JTDhEEoEQDvh0azyfbk3gf78fc1oMOQUWbl28lZj4s7w2eyBXR7az33DfMuOaQGAY3Paz6ZOa1MiI+dBrEvzyT6MURG2tfRG8W8jZQA1JIhCiCkXFVt5bbySAZTtOkl9UvuSB2QotVm59byvb4zN4ffZAJleUBLYugi/nQLtB8KcfILCCMwZnU8q4jTQwHL68Fc7ZuYPJUUk74PAPMHI
|
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"plt.plot(history.history['accuracy'], label='accuracy')\n",
|
|
|
|
"plt.plot(history.history['val_accuracy'], label = 'val_accuracy')\n",
|
|
|
|
"plt.xlabel('Epoch')\n",
|
|
|
|
"plt.ylabel('Accuracy')\n",
|
|
|
|
"plt.ylim([0.5, 1])\n",
|
|
|
|
"plt.legend(loc='lower right')\n",
|
|
|
|
"\n",
|
|
|
|
"test_loss, test_acc = model.evaluate(X_test, y_test, verbose=2)\n",
|
|
|
|
"\n",
|
|
|
|
"print(test_loss)\n",
|
|
|
|
"print(test_acc)"
|
|
|
|
]
|
2021-12-04 18:01:55 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "21696ef3",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "ebd5b1c1",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "57828ac4",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "1893f9da",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "a1448617",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.8.8"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|