Spaces:
Configuration error
Configuration error
Upload 12 files
Browse files
1.jpg
ADDED
2.jpg
ADDED
3.jpg
ADDED
4.jpg
ADDED
5.jpg
ADDED
6.jpg
ADDED
7.jpg
ADDED
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 Santosh Chavala
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,13 +1 @@
|
|
1 |
-
|
2 |
-
title: BrainTumor
|
3 |
-
emoji: 📚
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: yellow
|
6 |
-
sdk: streamlit
|
7 |
-
sdk_version: 1.33.0
|
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
|
|
|
1 |
+
# BrainTumor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
brain.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5b61b61648bbe257a15b84852904838af8743a32fda5073cfa595e141318bbfa
|
3 |
+
size 85885376
|
brain_tumor_detection.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
predictions.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
+
from tensorflow.keras.models import load_model
|
5 |
+
|
6 |
+
# Load the pre-trained model
|
7 |
+
model = load_model('brain.h5')
|
8 |
+
|
9 |
+
# Class labels
|
10 |
+
class_labels = ['glioma_tumor', 'meningioma_tumor', 'no_tumor', 'pituitary_tumor']
|
11 |
+
|
12 |
+
def load_and_predict(image):
|
13 |
+
# Preprocess the image for prediction
|
14 |
+
image = cv2.resize(image, (150, 150)) # Resize the image to match the input shape of the model
|
15 |
+
image = np.expand_dims(image, axis=0) # Add an extra dimension for batch size
|
16 |
+
|
17 |
+
# Make predictions
|
18 |
+
predictions = model.predict(image)
|
19 |
+
predicted_class_idx = np.argmax(predictions)
|
20 |
+
predicted_class = class_labels[predicted_class_idx]
|
21 |
+
|
22 |
+
return predicted_class
|
23 |
+
|
24 |
+
def main():
|
25 |
+
st.title("Brain Tumor Classifier")
|
26 |
+
|
27 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
28 |
+
|
29 |
+
if uploaded_file is not None:
|
30 |
+
image = cv2.imdecode(np.fromstring(uploaded_file.read(), np.uint8), 1)
|
31 |
+
st.image(image, caption="Uploaded Image.", width=200)
|
32 |
+
|
33 |
+
if st.button("Predict"):
|
34 |
+
predicted_class = load_and_predict(image)
|
35 |
+
st.success(f"Predicted Class: {predicted_class}")
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
main()
|