Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,17 @@ import gradio as gr
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
from keras.models import load_model
|
5 |
-
from tensorflow.keras.
|
6 |
|
7 |
-
# Charger le modèle
|
8 |
-
model = load_model('best_model.h5')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
def format_decimal(value):
|
11 |
decimal_value = format(value, ".2f")
|
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
from keras.models import load_model
|
5 |
+
from tensorflow.keras.preprocessing.image import load_img, img_to_array
|
6 |
|
7 |
+
# Charger le modèle sans compilation
|
8 |
+
model = load_model('best_model.h5', compile=False)
|
9 |
+
|
10 |
+
# Recompiler le modèle avec la fonction de perte et l'optimiseur appropriés
|
11 |
+
model.compile(
|
12 |
+
optimizer='adam',
|
13 |
+
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
|
14 |
+
metrics=['accuracy']
|
15 |
+
)
|
16 |
|
17 |
def format_decimal(value):
|
18 |
decimal_value = format(value, ".2f")
|