import gradio as gr import tensorflow as tf import numpy as np import os import tensorflow as tf import numpy as np from keras.models import load_model from tensorflow.keras.utils import load_img # Charger le modèle model = load_model('model_multi.h5') def detect(img): prediction = model.predict(img)[0] print(prediction) def format_decimal(value): decimal_value = format(value, ".2f") return decimal_value if format_decimal(prediction[0]) >= "0.5": return "Bactérie détectée" if format_decimal(prediction[1]) >= "0.5": return "Poumon sain" if format_decimal(prediction[2]) >= "0.5": return "Virus détecté" # result = detect(img) # print(result) os.system("tar -zxvf examples.tar.gz") input = gr.inputs.Image(shape=(100, 100)) title = "PneumoDetect: Pneumonia Detection from Chest X-Rays" iface = gr.Interface(fn=detect, inputs=input, outputs="text", examples_per_page=20, title=title) iface.launch(inline=False)