Spaces:
Sleeping
Sleeping
from tensorflow.keras.preprocessing.image import load_img, img_to_array | |
import numpy as np | |
import cv2 | |
import gradio as gd | |
from keras.models import load_model | |
model2 = load_model("./my_model.keras") | |
def predict(image): | |
image=cv2.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) |