File size: 1,079 Bytes
207caa9
 
f7bb60b
207caa9
 
266d9f5
 
207caa9
efa7843
207caa9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from tensorflow.keras.preprocessing.image import load_img, img_to_array
import numpy as np
import opencv as op
import gradio as gd
from keras.models import load_model
model2 = load_model("./my_model.keras")

def predict(image):
    image=op.resize(image,(240,240))
    image=img_to_array(image)/255.0
    image = np.expand_dims(image, axis=0)  
    prediction=model2.predict(image)
    predictions=np.array(prediction)
    predicted_index=np.argmax(predictions)
    index_to_class={0:'Disease : Alzheimer  || Type : Moderate_Demented',
      1:'Disease : Alzheimer || Type : MildDemented',
     2:'Disease : Alzheimer || Type : VeryMildDemented',
            3:'Disease : tumor ||  Type : glioma',
           4:'Disease :tumor ||  Type : meningioma',   
           5: 'Disease : tumor  || Type : pituitary',
               6:'Disease : None'}
    predicted_class_name=index_to_class[predicted_index]
    return predicted_class_name
    

headline="BRAIN DISEASE DETECTION "
a=gd.Interface(predict,inputs=gd.Image(),outputs="text",title=headline)
a.launch(share=True, debug=False)