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('/content/drive/MyDrive/T-DEV-810/model_cv.h5') # Charger l'image img = load_img('/content/drive/MyDrive/T-DEV-810/DS/test/NORMAL/IM-0063-0001.jpeg', target_size=(100, 100)) # Prétraiter l'image # img = image.img_to_array(img) img = np.expand_dims(img, axis=0) img = img/255 def detect(img): prediction = model.predict(img)[0] print(prediction) if prediction[0] <= 0.80: return "Pneumonia Detected!" return "Pneumonia Not Detected!" result = detect(img) print(result) os.system("tar -zxvf examples.tar.gz") input = gr.inputs.Image(shape=(100, 100)) examples = ['examples/n1.jpeg', 'examples/n2.jpeg', 'examples/n3.jpeg', 'examples/n4.jpeg', 'examples/n5.jpeg', 'examples/n6.jpeg', 'examples/n7.jpeg', 'examples/n8.jpeg', 'examples/p6.jpeg', 'examples/p7.jpeg', 'examples/p1.jpeg', 'examples/p2.jpeg', 'examples/p3.jpeg', 'examples/p4.jpeg', 'examples/p8.jpeg'] title = "PneumoDetect: Pneumonia Detection from Chest X-Rays" iface = gr.Interface(fn=detect, inputs=input, outputs="text", examples=examples, examples_per_page=20, title=title) iface.launch(inline=False)