Commit edfa7401 authored by Paranagama R.P.S.D.'s avatar Paranagama R.P.S.D.

feat : Updated notebook

parent 9ab80463
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"id": "ade37944",
"metadata": {},
"outputs": [],
......@@ -17,7 +17,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "16176bf6",
"metadata": {},
"outputs": [
......@@ -40,7 +40,7 @@
" 'Uhh']"
]
},
"execution_count": 3,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
......@@ -57,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"id": "8f7b1301",
"metadata": {},
"outputs": [],
......@@ -83,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "c9034cbe",
"metadata": {},
"outputs": [],
......@@ -113,7 +113,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "7adb379e",
"metadata": {},
"outputs": [],
......@@ -124,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "d44f7806",
"metadata": {},
"outputs": [],
......@@ -144,49 +144,12 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "ff4f0d06",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 3.0344 - accuracy: 0.0708 - val_loss: 2.4118 - val_accuracy: 0.1034\n",
"Epoch 2/10\n",
"4/4 [==============================] - 4s 1s/step - loss: 2.3133 - accuracy: 0.3274 - val_loss: 1.6620 - val_accuracy: 0.9310\n",
"Epoch 3/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 1.2560 - accuracy: 0.9558 - val_loss: 0.4894 - val_accuracy: 0.9655\n",
"Epoch 4/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 0.2415 - accuracy: 0.9912 - val_loss: 0.0362 - val_accuracy: 1.0000\n",
"Epoch 5/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 0.0340 - accuracy: 0.9912 - val_loss: 0.0024 - val_accuracy: 1.0000\n",
"Epoch 6/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 0.0021 - accuracy: 1.0000 - val_loss: 0.0127 - val_accuracy: 1.0000\n",
"Epoch 7/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 0.0040 - accuracy: 1.0000 - val_loss: 3.6882e-05 - val_accuracy: 1.0000\n",
"Epoch 8/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 9.9268e-05 - accuracy: 1.0000 - val_loss: 2.7212e-06 - val_accuracy: 1.0000\n",
"Epoch 9/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 5.2195e-05 - accuracy: 1.0000 - val_loss: 6.4126e-07 - val_accuracy: 1.0000\n",
"Epoch 10/10\n",
"4/4 [==============================] - 5s 1s/step - loss: 1.3251e-05 - accuracy: 1.0000 - val_loss: 2.7130e-07 - val_accuracy: 1.0000\n"
]
},
{
"data": {
"text/plain": [
"<keras.callbacks.History at 0x2d653970160>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])\n",
"model.fit(train_data, train_labels, epochs=EPOCHS, batch_size=BATCH_SIZE, validation_data=(val_data, val_labels))\n"
......@@ -194,40 +157,18 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"id": "61d6a8d8",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op while saving (showing 3 of 3). These functions will not be directly callable after loading.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: ./models/model\\assets\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:tensorflow:Assets written to: ./models/model\\assets\n"
]
}
],
"outputs": [],
"source": [
"model.save('./models/model')"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "dc610fdb",
"execution_count": null,
"id": "fdc9bfe6",
"metadata": {},
"outputs": [],
"source": [
......@@ -255,22 +196,10 @@
},
{
"cell_type": "code",
"execution_count": 11,
"id": "6b6d20d2",
"execution_count": null,
"id": "297e3e3c",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'test_data' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_17676\\3131021014.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mpredictions\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtest_data\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mpredicted_classes\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0margmax\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpredictions\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mNameError\u001b[0m: name 'test_data' is not defined"
]
}
],
"outputs": [],
"source": [
"predictions = model.predict(test_data)\n",
"predicted_classes = np.argmax(predictions, axis=1)\n",
......@@ -282,7 +211,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2bd77ac5",
"id": "e22211b0",
"metadata": {},
"outputs": [],
"source": [
......
......@@ -16,6 +16,9 @@
files/*
!files/
*.pyc
*~
*.swp
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python
......
import base64
import os
import cv2
from fastapi import APIRouter, File, HTTPException,UploadFile
import numpy as np
from pydantic import BaseModel
import tensorflow as tf
from core.logger import setup_logger
from core import setup_logger
from services.translate_service import SignLanguagePredictionService
from utils import mappings
......
import logging
def setup_logger():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
# Create a file handler for logging to a file
file_handler = logging.FileHandler('app.log')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)
# Create a stream handler for logging to console
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
stream_handler.setFormatter(formatter)
# Add the handlers to the logger
logger.addHandler(file_handler)
logger.addHandler(stream_handler)
return logger
import logging
def setup_logger():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
# Create a file handler for logging to a file
file_handler = logging.FileHandler('app.log')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)
# Create a stream handler for logging to console
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
stream_handler.setFormatter(formatter)
# Add the handlers to the logger
logger.addHandler(file_handler)
logger.addHandler(stream_handler)
return logger
......@@ -2,7 +2,9 @@ from fastapi import FastAPI
from controllers import translate_controler, users_controller
from fastapi.responses import RedirectResponse
from fastapi.middleware.cors import CORSMiddleware
from core import setup_logger
from core.logger import setup_logger
app = FastAPI()
......
......@@ -5,10 +5,8 @@ import numpy as np
from fastapi import HTTPException, UploadFile
from typing import Dict
import tensorflow as tf
from core.logger import setup_logger
from core import setup_logger
from utils import mappings
logger = setup_logger()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment