ML_DEMO / app.py
cnasa's picture
Update app.py
97a762a
raw
history blame
2.43 kB
import pickle
import pandas as pd
import sklearn
import numpy as np
import gradio as gr
import imblearn
from ml_demo_gradio_function import *
import tensorflow as tf
from tensorflow.keras.applications import imagenet_utils
from tensorflow.keras.utils import img_to_array
from tensorflow.keras.models import load_model
import cv2
import pdfplumber
import re
from collections import namedtuple
#LOADING THE DATA
results = loading_data()
Xtrain = results["Xtrain"]
Ytrain = results["Ytrain"]
Xtest_encoded = results["Xtest_encoded"]
Ytest = results["Ytest"]
num_col_trans = results["num_col_trans"]
cat_col_trans = results["cat_col_trans"]
# POUR VGG16
my_input = gr.inputs.Image(shape=(224,224))
my_output = gr.Label(label="Resultat de la prédiction",num_top_classes=2)
output_valeur = gr.outputs.HTML(label="")
description = (
"Cette page vous montre le résultat de la prédiction effectuée par le modèle VGG16. Le resultat présente si un patient est tumeureux ou pas du tout"
)
vgg16_interface = gr.Interface(Prediction_VGG16, my_input,description=description, theme="huggingface",outputs = [output_valeur,my_output])
#---------------------------------------------------------------------------------------
# POUR DIABETES FICHIER PDF
input_file_PDF = gr.File(label='PDF')
text_output2 = gr.Label(label="Resultat de la prédiction",num_top_classes=3)
df_ouput = gr.Dataframe(label="Caractéristique du patient",
headers=["HighBP","HighChol", "CholCheck", "BMI", "Smoker","Stroke","HeartDiseaseorAttack",
"PhysActivity", "Fruits", "Veggies","HvyAlcoholConsump","AnyHealthcare", "NoDocbcCost", "GenHlth",
"MentHlth", "PhysHlth", "DiffWalk",
"Sex", "Age", "Education","Income"],
row_count=1,
col_count=(21)
)
output_valeurs = gr.outputs.HTML(label="")
diabtes_PDF_interface = gr.Interface(get_data_inputPDF, inputs=input_file_PDF,
outputs=[df_ouput,output_valeurs,text_output2]
)
#---------------------------------------------------------------------------------------
demo = gr.TabbedInterface([vgg16_interface, diabtes_PDF_interface], ["Détéction d'une tumeur", "(PDF) Diabétique, prédiabétique ou sain"])
demo.launch()
if __name__ =="__main__":
demo.launch(share=True)