File size: 586 Bytes
b12a850
 
 
 
b657d51
b12a850
 
 
 
 
 
 
35dd703
b12a850
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
import tensorflow as tf

model = tf.keras.models.load_model('best_model.h5')
categories = ["Normal","Pneumonia", "Tubercolosis"]

def classify(img):
    img = img.reshape((-1, 224, 224, 3))
    pred = model.predict(img)[0]
    return {categories[i]: float(pred[i]) for i in range(3)}

image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label(num_top_classes=3)
examples = ["Normal.png", "Tuberculosis.png", "Pneumonia.jpeg"]
    

intf = gr.Interface(classify,inputs=image, outputs=label, examples=examples, capture_session=True)
intf.launch(inline=False)