fruk19 commited on
Commit
b8efc2b
·
verified ·
1 Parent(s): e46d7a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
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
- from tensorflow.keras.models import model_from_json
16
 
17
- # Load model architecture from JSON
18
- with open('model_architecture.json', 'r') as json_file:
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*255).astype(np.uint8)
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)