DFisch commited on
Commit
82c22e3
1 Parent(s): 21c92d8

Update app.py

Browse files

Changed way of loading model

Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -48,8 +48,24 @@ uploaded_file = st.file_uploader("Please upload an image", type=["jpeg", "jpg",
48
 
49
  if uploaded_file is not None:
50
  #load models
51
- model_M1 = tf.keras.layers.TFSMLayer("IMVIP_Supplementary_Material/models/model1/") #tf.keras.models.load_model("IMVIP_Supplementary_Material/models/model1/")
52
- model_M2 = tf.keras.models.load_model("IMVIP_Supplementary_Material/models/model2/")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  # Convert the file to an opencv image.
55
  file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)
 
48
 
49
  if uploaded_file is not None:
50
  #load models
51
+ model_path1 = "IMVIP_Supplementary_Material/models/model1/"
52
+ model_path2 = "IMVIP_Supplementary_Material/models/model2/"
53
+
54
+ tfsm_layer1 = tf.keras.layers.TFSMLayer(model_path1, call_endpoint='serving_default')
55
+ tfsm_layer2 = tf.keras.layers.TFSMLayer(model_path2, call_endpoint='serving_default')
56
+
57
+ input_shape = (256, 256, 3)
58
+ inputs = Input(shape=input_shape)
59
+
60
+ #create the model
61
+ outputs1 = tfsm_layer1(inputs)
62
+ model_M1 = Model(inputs, outputs1)
63
+
64
+ outputs2 = tfsm_layer2(inputs)
65
+ model_M2 = Model(inputs, outputs2)
66
+
67
+ #model_M1 = tf.keras.layers.TFSMLayer("IMVIP_Supplementary_Material/models/model1/") #tf.keras.models.load_model("IMVIP_Supplementary_Material/models/model1/")
68
+ #model_M2 = tf.keras.models.load_model("IMVIP_Supplementary_Material/models/model2/")
69
 
70
  # Convert the file to an opencv image.
71
  file_bytes = np.asarray(bytearray(uploaded_file.read()), dtype=np.uint8)