Spaces:
Build error
Build error
Delete predict_glaucoma.py
Browse files- predict_glaucoma.py +0 -31
predict_glaucoma.py
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
|
3 |
-
|
4 |
-
import cv2
|
5 |
-
import numpy as np
|
6 |
-
import tensorflow as tf
|
7 |
-
from tensorflow import keras
|
8 |
-
|
9 |
-
def predict_glaucoma(image_path, model_path):
|
10 |
-
# Carrega o modelo de classificação
|
11 |
-
model = keras.models.load_model(model_path)
|
12 |
-
|
13 |
-
# Lê a imagem do arquivo temporário
|
14 |
-
input_image = cv2.imread(image_path, cv2.IMREAD_COLOR)
|
15 |
-
|
16 |
-
# Redimensiona a imagem para 256x256 pixels
|
17 |
-
resize_width = 256
|
18 |
-
resize_height = 256
|
19 |
-
input_image = cv2.resize(input_image, (resize_width, resize_height))
|
20 |
-
|
21 |
-
# Normaliza os valores de pixel da imagem
|
22 |
-
input_image = input_image.astype(np.float32) / 255.0
|
23 |
-
|
24 |
-
# Converte a imagem para escala de cinza
|
25 |
-
input_image = cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)
|
26 |
-
|
27 |
-
# Faz a previsão do modelo
|
28 |
-
input_tensor = np.expand_dims(input_image, axis=(0, -1))
|
29 |
-
prediction = model.predict(input_tensor)[0][0]
|
30 |
-
|
31 |
-
return prediction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|