Spaces:
Build error
Build error
File size: 1,094 Bytes
beec372 177137f beec372 177137f beec372 177137f beec372 177137f beec372 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | import gradio as gr
import tensorflow as tf
import numpy as np
import cv2
new_model = tf.keras.models.load_model('best_model_mammography.h5')
def classificar_imagem(file_name):
img1 = cv2.imread(file_name.name.replace("\\", '/'), 0)
img = cv2.resize(img1, (224, 224))
img = img.reshape(img.shape[0], img.shape[1], 1)
pred = new_model.predict(np.array([img]))
pred = np.round(pred, 1)
if pred == 0:
pred_label = "Benigno"
else:
pred_label = "Maligno"
pred_score = f"{float(pred) * 100:.2f}%"
return pred_label, pred_score
imagem = gr.inputs.File(file_count=1, label="Imagem de mamografia")
resultado_diagnostico = [gr.outputs.Textbox(label="Diagnóstico"), gr.outputs.Textbox(label="Confiança")]
gr.Interface(
fn=classificar_imagem,
inputs=imagem,
outputs=resultado_diagnostico,
interpretation="default",
live=True,
theme="dark-peach",
title="API BreastNet - Teste de diagnóstico de Câncer de Mama",
description="Esta API é usada para determinar se o câncer de mama é benigno ou maligno."
).launch()
|