Spaces:
Sleeping
Sleeping
File size: 1,524 Bytes
e81879a 3559626 05c62eb dc4e72f e81879a dc4e72f ba8079a d08200f 2679436 c7429e9 94fe01a 05c62eb ba8079a dc4e72f d08200f df3484f d31d503 e0fc5f0 d31d503 9100cce 1f0edc1 9100cce 1f0edc1 9100cce 1f0edc1 e0fc5f0 d31d503 e0fc5f0 d31d503 4ddb435 fb887f7 dc4e72f 07505b0 dc4e72f 2dfea56 ad0e7fc 4ddb435 05c62eb ba540df 05c62eb 02b6fa0 05c62eb |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
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 format_decimal(value):
decimal_value = format(value, ".2f")
return decimal_value
def detect(img):
img = np.expand_dims(img, axis=0)
img = img/255
prediction = model.predict(img)[0]
# Initialisation du texte
texte = ""
# Détermination du texte et de la couleur pour chaque classe
if format_decimal(prediction[0]) >= "0.5":
texte += 'Risque d\'infection bactérienne'
if format_decimal(prediction[1]) >= "0.5":
texte += 'Poumon sain'
if format_decimal(prediction[2]) >= "0.5":
texte += 'Risque d\'infection biologique'
if texte == "":
texte = "Classe indéterminée"
return texte
# result = detect(img)
# print(result)
os.system("tar -zxvf examples.tar.gz")
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',]
input = gr.inputs.Image(shape=(100,100))
title = "PneumoDetect: Detection de pneumonie par x-ray"
iface = gr.Interface(fn=detect, inputs=input, outputs=[gr.Textbox(label="Diagnostic", lines=10)],examples = examples, examples_per_page=20, title=title)
iface.launch(inline=False)
|