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

refactor : Model load error handling

parent 0a5e5619
import os
from fastapi import APIRouter, File, HTTPException, Query,UploadFile
from pydantic import BaseModel
import tensorflow as tf
......@@ -17,7 +18,16 @@ class ImageRequest(BaseModel):
# Load your Keras model
model = tf.keras.models.load_model('../ML_Models/sign_language_to_text/models/sign_language_model.h5')
# model = tf.keras.models.load_model('../ML_Models/sign_language_to_text/models/sign_language_model.h5')
model_file_path = '../ML_Models/sign_language_to_text/models/sign_language_model.h5'
# Check if the model file exists
if os.path.exists(model_file_path):
# Load the Keras model if the file exists
model = tf.keras.models.load_model(model_file_path)
else:
model = None
CLASSES = mappings.classes
NUM_CLASSES = len(mappings.classes) # number of classes
IMG_SIZE = 224 # image size
......
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