DHEIVER commited on
Commit
ef2cffe
·
1 Parent(s): 2d907f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -3,9 +3,23 @@ import tensorflow as tf
3
  import cv2
4
  import numpy as np
5
 
6
- # Load the TensorFlow model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  tf_model_path = 'modelo_treinado.h5' # Update with the path to your TensorFlow model
8
- tf_model = tf.keras.models.load_model(tf_model_path)
9
 
10
  class_labels = ["Normal", "Cataract"]
11
 
 
3
  import cv2
4
  import numpy as np
5
 
6
+ # Define the custom layer 'FixedDropout'
7
+ class FixedDropout(tf.keras.layers.Layer):
8
+ def __init__(self, rate, **kwargs):
9
+ super(FixedDropout, self).__init__(**kwargs)
10
+ self.rate = rate
11
+
12
+ def call(self, inputs, training=None):
13
+ return tf.keras.backend.dropout(inputs, level=self.rate)
14
+
15
+ # Load the TensorFlow model with custom layer handling
16
+ def load_model_with_custom_objects(model_path):
17
+ with tf.keras.utils.custom_object_scope({'FixedDropout': FixedDropout}):
18
+ model = tf.keras.models.load_model(model_path)
19
+ return model
20
+
21
  tf_model_path = 'modelo_treinado.h5' # Update with the path to your TensorFlow model
22
+ tf_model = load_model_with_custom_objects(tf_model_path)
23
 
24
  class_labels = ["Normal", "Cataract"]
25