Spaces:
Runtime error
Runtime error
File size: 1,139 Bytes
0500aa4 |
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 36 |
import gradio as gr
import pandas as pd
import torch
import torch.nn.functional as F
from fastai.tabular.all import *
import pickle
with open('Kidney_stones.pkl', 'rb') as arquivo:
modelo = pickle.load(arquivo)
def calc_preds(coeffs, indeps):
layers,consts = coeffs
n = len(layers)
res = indeps
for i,l in enumerate(layers):
res = res@l + consts[i]
if i!=n-1: res = F.relu(res)
return torch.sigmoid(res)
def predict(Gravity, Ph, Osmo, Cond, Urea, Calc):
input = torch.tensor([Gravity, Ph, Osmo, Cond, Urea, Calc], dtype=torch.float)
pred = calc_preds(coeffs=modelo, indeps=input)
return 'Kidney Stone' if pred.item() < 0.55 else 'No Kidney Stones'
interface = gr.Interface(
fn=predict,
inputs=["number", "number", "number", "number", "number", "number"],
outputs="text",
layout="vertical",
title="Verificador de Pedras nos Rins",
description="Esse modelo é capaz de realizar uma análise com base nos dados da urina de uma pessoa e identificar se ela possui pedra nos rins",
interpretation="default",
enable_queue=True
)
interface.launch(share=True) |