Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,22 +50,22 @@ set_png_as_page_bg('background.webp')
|
|
| 50 |
# #CNN_class_index = json.load(open(f"{os.getcwd()}F:\Machine Learning Resources\ZebraHorse\model.json"))
|
| 51 |
# return model, CNN_class_index
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
|
| 60 |
-
def load_model():
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
|
| 71 |
def image_transformation(image):
|
|
@@ -106,7 +106,7 @@ def main():
|
|
| 106 |
# labels = ohe.fit_transform(label).toarray()
|
| 107 |
|
| 108 |
if pred_button:
|
| 109 |
-
image_prediction(image
|
| 110 |
outputs = model.predict(image)
|
| 111 |
_, y_hat = outputs.max(1)
|
| 112 |
predicted_idx = str(y_hat.item())
|
|
|
|
| 50 |
# #CNN_class_index = json.load(open(f"{os.getcwd()}F:\Machine Learning Resources\ZebraHorse\model.json"))
|
| 51 |
# return model, CNN_class_index
|
| 52 |
|
| 53 |
+
def load_model():
|
| 54 |
+
if not os.path.isfile('model.h5'):
|
| 55 |
+
subprocess.run(['curl --output model.h5 "https://github.com/KaburaJ/Binary-Image-classification/blob/main/ZebraHorse/CNN%20Application/model.h5"'], shell=True)
|
| 56 |
|
| 57 |
+
tf.keras.models.load_model('model.h5', compile=False)
|
| 58 |
+
return model
|
| 59 |
|
| 60 |
+
# def load_model():
|
| 61 |
+
# # Load the model architecture
|
| 62 |
+
# with open('model.json', 'r') as f:
|
| 63 |
+
# model_from_json(f.read())
|
| 64 |
|
| 65 |
+
# # Load the model weights
|
| 66 |
+
# model.load_weights('model.h5')
|
| 67 |
+
# #CNN_class_index = json.load(open(f"{os.getcwd()}F:\Machine Learning Resources\ZebraHorse\model.json"))
|
| 68 |
+
# return model
|
| 69 |
|
| 70 |
|
| 71 |
def image_transformation(image):
|
|
|
|
| 106 |
# labels = ohe.fit_transform(label).toarray()
|
| 107 |
|
| 108 |
if pred_button:
|
| 109 |
+
image_prediction(image)
|
| 110 |
outputs = model.predict(image)
|
| 111 |
_, y_hat = outputs.max(1)
|
| 112 |
predicted_idx = str(y_hat.item())
|