Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
-
import cv2
|
5 |
from PIL import Image, ImageDraw, ImageFont
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# Carregue seu modelo TensorFlow treinado
|
8 |
-
|
|
|
9 |
|
10 |
# Defina uma função para fazer previsões
|
11 |
def classify_image(input_image):
|
|
|
1 |
import gradio as gr
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
|
|
4 |
from PIL import Image, ImageDraw, ImageFont
|
5 |
|
6 |
+
# Defina a camada personalizada FixedDropout
|
7 |
+
class FixedDropout(tf.keras.layers.Dropout):
|
8 |
+
def _get_noise_shape(self, inputs):
|
9 |
+
if self.noise_shape is None:
|
10 |
+
return self.noise_shape
|
11 |
+
symbolic_shape = tf.shape(inputs)
|
12 |
+
noise_shape = [symbolic_shape[axis] if shape is None else shape
|
13 |
+
for axis, shape in enumerate(self.noise_shape)]
|
14 |
+
return tuple(noise_shape)
|
15 |
+
|
16 |
+
# Registre a camada personalizada FixedDropout
|
17 |
+
tf.keras.utils.get_custom_objects()['FixedDropout'] = FixedDropout
|
18 |
+
|
19 |
# Carregue seu modelo TensorFlow treinado
|
20 |
+
with tf.keras.utils.custom_object_scope({'FixedDropout': FixedDropout}):
|
21 |
+
model = tf.keras.models.load_model('modelo_treinado.h5')
|
22 |
|
23 |
# Defina uma função para fazer previsões
|
24 |
def classify_image(input_image):
|