Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ import numpy as np
|
|
11 |
import tensorflow as tf
|
12 |
from huggingface_hub import snapshot_download
|
13 |
|
|
|
|
|
14 |
|
15 |
# global variables
|
16 |
# predictions from:
|
@@ -72,8 +74,9 @@ def download_keras_model():
|
|
72 |
print(f"Download dir: {download_dir}")
|
73 |
keras_binary_path = os.path.join(download_dir, keras_binary_label)
|
74 |
print(f"Keras binary label: {keras_binary_path}")
|
75 |
-
|
76 |
-
|
|
|
77 |
# local testing
|
78 |
# check if the model exists
|
79 |
# binary label
|
@@ -86,7 +89,7 @@ def download_keras_model():
|
|
86 |
)
|
87 |
if not os.path.exists(model_path):
|
88 |
print(f"Model not found: {model_path}")
|
89 |
-
# load keras model
|
90 |
keras_binary_model = tf.keras.models.load_model(model_path)
|
91 |
|
92 |
# Check with model loaded
|
@@ -102,8 +105,7 @@ def download_keras_model():
|
|
102 |
)
|
103 |
if not os.path.exists(model_path):
|
104 |
print(f"Model not found: {model_path}")
|
105 |
-
# load keras model
|
106 |
-
|
107 |
keras_multi_model = tf.keras.models.load_model(model_path)
|
108 |
|
109 |
# In HF space, load model from repository
|
@@ -114,7 +116,9 @@ def download_keras_model():
|
|
114 |
print(f"Download dir: {download_dir}")
|
115 |
keras_multi_path = os.path.join(download_dir, keras_multilabel)
|
116 |
print(f"Keras multi label: {keras_multi_path}")
|
117 |
-
|
|
|
|
|
118 |
|
119 |
# Check with model loaded
|
120 |
print(f"\nLoaded model: {keras_multi_model.name}")
|
|
|
11 |
import tensorflow as tf
|
12 |
from huggingface_hub import snapshot_download
|
13 |
|
14 |
+
# check the tensoflow version
|
15 |
+
print(f"tensorflow version: {tf.__version__}")
|
16 |
|
17 |
# global variables
|
18 |
# predictions from:
|
|
|
74 |
print(f"Download dir: {download_dir}")
|
75 |
keras_binary_path = os.path.join(download_dir, keras_binary_label)
|
76 |
print(f"Keras binary label: {keras_binary_path}")
|
77 |
+
# this load() does not work in HF
|
78 |
+
#keras_binary_model = tf.keras.models.load(keras_binary_path)
|
79 |
+
keras_binary_model = tf.keras.saving.load_model(keras_binary_path)
|
80 |
# local testing
|
81 |
# check if the model exists
|
82 |
# binary label
|
|
|
89 |
)
|
90 |
if not os.path.exists(model_path):
|
91 |
print(f"Model not found: {model_path}")
|
92 |
+
# load local keras model
|
93 |
keras_binary_model = tf.keras.models.load_model(model_path)
|
94 |
|
95 |
# Check with model loaded
|
|
|
105 |
)
|
106 |
if not os.path.exists(model_path):
|
107 |
print(f"Model not found: {model_path}")
|
108 |
+
# load local keras model
|
|
|
109 |
keras_multi_model = tf.keras.models.load_model(model_path)
|
110 |
|
111 |
# In HF space, load model from repository
|
|
|
116 |
print(f"Download dir: {download_dir}")
|
117 |
keras_multi_path = os.path.join(download_dir, keras_multilabel)
|
118 |
print(f"Keras multi label: {keras_multi_path}")
|
119 |
+
# load() does not work in HF
|
120 |
+
#keras_multi_model = tf.keras.models.load(keras_multi_path)
|
121 |
+
keras_multi_model = tf.keras.saving.load_model(keras_multi_path)
|
122 |
|
123 |
# Check with model loaded
|
124 |
print(f"\nLoaded model: {keras_multi_model.name}")
|