Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,15 +12,10 @@ from image_call import (create_image_ndvi,
|
|
| 12 |
create_image_from_coordinates)
|
| 13 |
import numpy as np
|
| 14 |
from PIL import Image
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
loaded_model_json = json_file.read()
|
| 20 |
-
loaded_model = model_from_json(loaded_model_json)
|
| 21 |
-
|
| 22 |
-
# Load weights into the loaded model
|
| 23 |
-
loaded_model.load_weights("model_weights.h5")
|
| 24 |
|
| 25 |
def process_input(file):
|
| 26 |
df_use = load_and_process_file(file)
|
|
@@ -40,7 +35,7 @@ def process_input(file):
|
|
| 40 |
input_to_model = np.expand_dims(np_img_use, axis=0)
|
| 41 |
|
| 42 |
predictions = loaded_model.predict(input_to_model)
|
| 43 |
-
predictions = np.squeeze(predictions
|
| 44 |
return_image = Image.fromarray(predictions).convert("RGB")
|
| 45 |
|
| 46 |
path_save_img = "test.png"
|
|
@@ -57,4 +52,4 @@ iface = gr.Interface(
|
|
| 57 |
)
|
| 58 |
|
| 59 |
# รัน Gradio interface
|
| 60 |
-
iface.launch()
|
|
|
|
| 12 |
create_image_from_coordinates)
|
| 13 |
import numpy as np
|
| 14 |
from PIL import Image
|
| 15 |
+
import tensorflow as tf
|
| 16 |
|
| 17 |
+
# โหลดโมเดล
|
| 18 |
+
loaded_model = tf.keras.models.load_model('combind_model.h5')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def process_input(file):
|
| 21 |
df_use = load_and_process_file(file)
|
|
|
|
| 35 |
input_to_model = np.expand_dims(np_img_use, axis=0)
|
| 36 |
|
| 37 |
predictions = loaded_model.predict(input_to_model)
|
| 38 |
+
predictions = np.squeeze(predictions).astype(np.uint8)
|
| 39 |
return_image = Image.fromarray(predictions).convert("RGB")
|
| 40 |
|
| 41 |
path_save_img = "test.png"
|
|
|
|
| 52 |
)
|
| 53 |
|
| 54 |
# รัน Gradio interface
|
| 55 |
+
iface.launch(share=True)
|