Spaces:
Sleeping
Sleeping
Matej
commited on
Commit
•
4b555a1
1
Parent(s):
5e00ad7
Set gloabal policy (float32)
Browse files
my_app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
from huggingface_hub import from_pretrained_keras
|
|
|
4 |
|
5 |
# Load your trained models
|
6 |
model1 = from_pretrained_keras("ml-debi/EfficientNetB0-Food101")
|
@@ -36,8 +37,11 @@ def predict(image):
|
|
36 |
#model = model1 if model_selection == "EfficentNetB0 Fine Tune" else model2
|
37 |
|
38 |
#print(model.summary())
|
|
|
|
|
39 |
|
40 |
image = preprocess(image)
|
|
|
41 |
prediction = model1.predict(image)
|
42 |
print("model prediction", prediction)
|
43 |
predicted_class = classes[int(tf.argmax(prediction, axis=1))]
|
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
from huggingface_hub import from_pretrained_keras
|
4 |
+
from tensorflow.keras import mixed_precision
|
5 |
|
6 |
# Load your trained models
|
7 |
model1 = from_pretrained_keras("ml-debi/EfficientNetB0-Food101")
|
|
|
37 |
#model = model1 if model_selection == "EfficentNetB0 Fine Tune" else model2
|
38 |
|
39 |
#print(model.summary())
|
40 |
+
if mixed_precision.global_policy() == "mixed_float16":
|
41 |
+
mixed_precision.set_global_policy(policy="float32")
|
42 |
|
43 |
image = preprocess(image)
|
44 |
+
print(mixed_precision.global_policy())
|
45 |
prediction = model1.predict(image)
|
46 |
print("model prediction", prediction)
|
47 |
predicted_class = classes[int(tf.argmax(prediction, axis=1))]
|