DHEIVER commited on
Commit
abed96a
·
1 Parent(s): 2283b5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -2,10 +2,23 @@ import gradio as gr
2
  import tensorflow as tf
3
  import numpy as np
4
 
5
- # Load your trained TensorFlow model
6
- model = tf.keras.models.load_model('modelo_treinado.h5') # Load your saved model
 
 
 
 
 
 
 
7
 
8
- # Define a function to make predictions
 
 
 
 
 
 
9
  def classify_image(input_image):
10
  # Redimensione a imagem para as dimensões corretas (192x256)
11
  input_image = tf.image.resize(input_image, (192, 256)) # Redimensione para as dimensões esperadas
 
2
  import tensorflow as tf
3
  import numpy as np
4
 
5
+ # Defina a camada personalizada FixedDropout
6
+ class FixedDropout(tf.keras.layers.Dropout):
7
+ def _get_noise_shape(self, inputs):
8
+ if self.noise_shape is None:
9
+ return self.noise_shape
10
+ symbolic_shape = tf.shape(inputs)
11
+ noise_shape = [symbolic_shape[axis] if shape is None else shape
12
+ for axis, shape in enumerate(self.noise_shape)]
13
+ return tuple(noise_shape)
14
 
15
+ # Registre a camada personalizada FixedDropout
16
+ tf.keras.utils.get_custom_objects()['FixedDropout'] = FixedDropout
17
+
18
+ # Carregue seu modelo TensorFlow treinado
19
+ model = tf.keras.models.load_model('modelo_treinado.h5')
20
+
21
+ # Defina uma função para fazer previsões
22
  def classify_image(input_image):
23
  # Redimensione a imagem para as dimensões corretas (192x256)
24
  input_image = tf.image.resize(input_image, (192, 256)) # Redimensione para as dimensões esperadas