Spaces:
Running
Running
Update main.py
Browse files
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(
|
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.")
|