Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
import cv2
|
| 5 |
+
|
| 6 |
+
new_model = tf.keras.models.load_model('best_model_mammography.h5')
|
| 7 |
+
|
| 8 |
+
def classificar_imagem(file_name):
|
| 9 |
+
img1 = cv2.imread(file_name.name.replace("\\", '/'), 0)
|
| 10 |
+
img = cv2.resize(img1, (224, 224))
|
| 11 |
+
img = img.reshape(img.shape[0], img.shape[1], 1)
|
| 12 |
+
pred = new_model.predict(np.array([img]))
|
| 13 |
+
pred = np.round(pred, 1)
|
| 14 |
+
if pred == 0:
|
| 15 |
+
pred = "Benigno"
|
| 16 |
+
else:
|
| 17 |
+
pred = "Maligno"
|
| 18 |
+
return pred
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
imagem = gr.inputs.File(file_count=1, label="Arquivo a ser analisado (extens茫o .pgm)")
|
| 22 |
+
texto_saida = gr.outputs.Textbox(label="Resultado do diagn贸stico")
|
| 23 |
+
|
| 24 |
+
gr.Interface(
|
| 25 |
+
fn=classificar_imagem,
|
| 26 |
+
inputs=imagem,
|
| 27 |
+
outputs=texto_saida,
|
| 28 |
+
interpretation="default",
|
| 29 |
+
live=True,
|
| 30 |
+
theme="dark-peach",
|
| 31 |
+
title="API BreastNet - Teste de diagn贸stico de C芒ncer de Mama",
|
| 32 |
+
description="Esta API 茅 usada para determinar se o c芒ncer de mama 茅 benigno ou maligno."
|
| 33 |
+
).launch()
|