Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,6 @@ import tensorflow as tf
|
|
3 |
import numpy as np
|
4 |
import cv2
|
5 |
from tensorflow.keras.layers import DepthwiseConv2D
|
6 |
-
import matplotlib.pyplot as plt
|
7 |
-
import io
|
8 |
from PIL import Image
|
9 |
|
10 |
# Función personalizada para DepthwiseConv2D
|
@@ -41,6 +39,10 @@ labels = [
|
|
41 |
]
|
42 |
|
43 |
def generate_heatmap(image, prediction):
|
|
|
|
|
|
|
|
|
44 |
# Crear un mapa de calor basado en la predicción
|
45 |
heatmap = np.mean(prediction, axis=-1) # Promediar los canales de predicción
|
46 |
heatmap = np.maximum(heatmap, 0) # Aplicar ReLU
|
|
|
3 |
import numpy as np
|
4 |
import cv2
|
5 |
from tensorflow.keras.layers import DepthwiseConv2D
|
|
|
|
|
6 |
from PIL import Image
|
7 |
|
8 |
# Función personalizada para DepthwiseConv2D
|
|
|
39 |
]
|
40 |
|
41 |
def generate_heatmap(image, prediction):
|
42 |
+
# Asegurarse de que image sea un array de NumPy
|
43 |
+
if not isinstance(image, np.ndarray):
|
44 |
+
image = np.array(image)
|
45 |
+
|
46 |
# Crear un mapa de calor basado en la predicción
|
47 |
heatmap = np.mean(prediction, axis=-1) # Promediar los canales de predicción
|
48 |
heatmap = np.maximum(heatmap, 0) # Aplicar ReLU
|