Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from tensorflow.keras.preprocessing.image import load_img, img_to_array
|
| 2 |
+
import numpy as np
|
| 3 |
+
import cv2
|
| 4 |
+
import gradio as gd
|
| 5 |
+
from keras.models import load_model
|
| 6 |
+
model2 = load_model()
|
| 7 |
+
def predict(image):
|
| 8 |
+
image=cv2.resize(image,(240,240))
|
| 9 |
+
image=img_to_array(image)/255.0
|
| 10 |
+
image = np.expand_dims(image, axis=0)
|
| 11 |
+
prediction=model2.predict(image)
|
| 12 |
+
predictions=np.array(prediction)
|
| 13 |
+
predicted_index=np.argmax(predictions)
|
| 14 |
+
index_to_class={0:'Disease : Alzheimer || Type : Moderate_Demented',
|
| 15 |
+
1:'Disease : Alzheimer || Type : MildDemented',
|
| 16 |
+
2:'Disease : Alzheimer || Type : VeryMildDemented',
|
| 17 |
+
3:'Disease : tumor || Type : glioma',
|
| 18 |
+
4:'Disease :tumor || Type : meningioma',
|
| 19 |
+
5: 'Disease : tumor || Type : pituitary',
|
| 20 |
+
6:'Disease : None'}
|
| 21 |
+
predicted_class_name=index_to_class[predicted_index]
|
| 22 |
+
return predicted_class_name
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
headline="BRAIN DISEASE DETECTION "
|
| 26 |
+
a=gd.Interface(predict,inputs=gd.Image(),outputs="text",title=headline)
|
| 27 |
+
a.launch(share=True, debug=False)
|