navpan2 commited on
Commit
c4fe336
·
verified ·
1 Parent(s): f4e9f49

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -1
main.py CHANGED
@@ -9,6 +9,11 @@ from tensorflow.keras.preprocessing.image import img_to_array
9
  from tensorflow.keras.applications import resnet50
10
  from tensorflow.keras.applications.resnet50 import preprocess_input
11
  import uvicorn
 
 
 
 
 
12
 
13
  # Initialize FastAPI app
14
  app = FastAPI()
@@ -59,7 +64,7 @@ class_labels = {
59
 
60
  # Load the model if it exists
61
  if os.path.exists(model_path):
62
- model = tf.keras.models.load_model(model_path)
63
  print("Model loaded successfully.")
64
  else:
65
  print(f"Model file not found at {model_path}. Please upload the model.")
 
9
  from tensorflow.keras.applications import resnet50
10
  from tensorflow.keras.applications.resnet50 import preprocess_input
11
  import uvicorn
12
+ import tensorflow_addons as tfa
13
+ # Load the h5 model
14
+ custom_objects = {
15
+ "Addons>CohenKappa": tfa.metrics.CohenKappa,
16
+ }
17
 
18
  # Initialize FastAPI app
19
  app = FastAPI()
 
64
 
65
  # Load the model if it exists
66
  if os.path.exists(model_path):
67
+ model = tf.keras.models.load_model('model.h5', custom_objects=custom_objects)
68
  print("Model loaded successfully.")
69
  else:
70
  print(f"Model file not found at {model_path}. Please upload the model.")