Spaces:
Sleeping
Sleeping
Upload 9 files
Browse files- .gitattributes +1 -0
- BrainTumor10Epochs.h5 +3 -0
- README.md +13 -0
- app.py +45 -0
- example_images/No_1.jpg +0 -0
- example_images/No_2.jpg +0 -0
- example_images/No_3.jpg +0 -0
- example_images/Yes_2.jpg +0 -0
- example_images/Yes_3.jpg +0 -0
- requirements.txt +6 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
BrainTumor10Epochs.h5 filter=lfs diff=lfs merge=lfs -text
|
BrainTumor10Epochs.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:236b657176a4c29999932cfa9a2f34efcb180c937d1e5cef07d959c7f661ca22
|
| 3 |
+
size 2174240
|
README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Brain Tumor Classification
|
| 3 |
+
emoji: 🏢
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.40.1
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
import tensorflow as tf
|
| 6 |
+
from keras.models import load_model
|
| 7 |
+
|
| 8 |
+
import gradio as gr
|
| 9 |
+
|
| 10 |
+
model =load_model('BrainTumor10Epochs.h5')
|
| 11 |
+
|
| 12 |
+
def getResult(inp):
|
| 13 |
+
|
| 14 |
+
inp=np.array(inp)
|
| 15 |
+
input_img = np.expand_dims(inp, axis=0)
|
| 16 |
+
result=np.max(model.predict(input_img))
|
| 17 |
+
|
| 18 |
+
if result==0:
|
| 19 |
+
return "No Brain Tumor"
|
| 20 |
+
elif result==1:
|
| 21 |
+
|
| 22 |
+
return "Yes Brain Tumor"
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
examples = [
|
| 27 |
+
["example_images/No_1.jpg"],
|
| 28 |
+
["example_images/No_2.jpg"],
|
| 29 |
+
["example_images/No_3.jpg"],
|
| 30 |
+
["example_images/Yes_2.jpg"],
|
| 31 |
+
["example_images/Yes_3.jpg"]
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
iface = gr.Interface(
|
| 36 |
+
fn=getResult,
|
| 37 |
+
inputs=gr.Image(shape=(64, 64),label="MRI Image"),
|
| 38 |
+
outputs=gr.Label(num_top_classes=2,label="Output"),
|
| 39 |
+
title="Brain Tumor Classification",
|
| 40 |
+
description="Upload the MRI Image of the Brain and it will tell whether it has a Brain Tumor or not",
|
| 41 |
+
examples=examples,
|
| 42 |
+
theme=gr.themes.Default(primary_hue="teal", secondary_hue="cyan"), allow_flagging=False
|
| 43 |
+
)
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
iface.launch()
|
example_images/No_1.jpg
ADDED
|
example_images/No_2.jpg
ADDED
|
example_images/No_3.jpg
ADDED
|
example_images/Yes_2.jpg
ADDED
|
example_images/Yes_3.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
opencv-python
|
| 2 |
+
numpy
|
| 3 |
+
Pillow
|
| 4 |
+
tensorflow
|
| 5 |
+
keras
|
| 6 |
+
gradio
|