Spaces:
Configuration error
Configuration error
Upload 7 files
Browse files- .gitattributes +2 -0
- Normal- (9).jpg +3 -0
- Normal- good(6).jpg +3 -0
- README.md +10 -12
- Tumor- (872).jpg +0 -0
- Tumor- (882).jpg +0 -0
- app.py +47 -0
- requirements.txt +5 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
Normal-[[:space:]](9).jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
Normal-[[:space:]]good(6).jpg filter=lfs diff=lfs merge=lfs -text
|
Normal- (9).jpg
ADDED
![]() |
Git LFS Details
|
Normal- good(6).jpg
ADDED
![]() |
Git LFS Details
|
README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
# π§ Kidney CT Classifier
|
2 |
+
|
3 |
+
A machine learning web app to classify kidney CT scans as NORMAL or ABNORMAL.
|
4 |
+
|
5 |
+
## π Live Demo
|
6 |
+
|
7 |
+
π [Launch Here](https://huggingface.co/spaces/your-username/kidney-ct-classifier)
|
8 |
+
|
9 |
+
## Sample Images
|
10 |
+
Includes `images/sample1.png` and `images/sample2.png` to try the app.
|
|
|
|
Tumor- (872).jpg
ADDED
![]() |
Tumor- (882).jpg
ADDED
![]() |
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
+
from tensorflow.keras.models import load_model
|
5 |
+
from huggingface_hub import hf_hub_download
|
6 |
+
|
7 |
+
model_path = hf_hub_download(repo_id="TaliZG03/kidney_normal_CT_classifier_model", filename="model.keras")
|
8 |
+
model = load_model(model_path)
|
9 |
+
|
10 |
+
def preprocess(image):
|
11 |
+
image = image.resize((300, 300)).convert("RGB")
|
12 |
+
image = np.array(image) / 255.0
|
13 |
+
return np.expand_dims(image, axis=0)
|
14 |
+
|
15 |
+
def predict(image):
|
16 |
+
input_array = preprocess(image)
|
17 |
+
prediction = model.predict(input_array)[0][0]
|
18 |
+
label = "NORMAL" if prediction >= 0.5 else "ABNORMAL"
|
19 |
+
confidence = prediction if label == "NORMAL" else 1 - prediction
|
20 |
+
|
21 |
+
if label == "NORMAL" and confidence >= 0.7:
|
22 |
+
explanation = "β
The kidney CT scan appears normal with high confidence."
|
23 |
+
attention_flag = ""
|
24 |
+
elif label == "NORMAL" and confidence < 0.7:
|
25 |
+
explanation = "β οΈ The scan appears normal, but the model's confidence is low. Consider radiologist review."
|
26 |
+
attention_flag = "π¨ FLAGGED FOR RADIOLOGIST REVIEW"
|
27 |
+
else:
|
28 |
+
explanation = "β οΈ The kidney CT scan shows signs of abnormality. Immediate radiologist attention is recommended."
|
29 |
+
attention_flag = "π¨ FLAGGED FOR RADIOLOGIST REVIEW"
|
30 |
+
|
31 |
+
return f""" Prediction: {label}
|
32 |
+
π Confidence: {confidence:.2%}
|
33 |
+
|
34 |
+
{explanation}
|
35 |
+
{attention_flag}"""
|
36 |
+
|
37 |
+
demo = gr.Interface(
|
38 |
+
fn=predict,
|
39 |
+
inputs=gr.Image(type="pil"),
|
40 |
+
outputs="text",
|
41 |
+
title="Kidney CT Classifier",
|
42 |
+
description="Upload a kidney CT image. The model will predict if it's NORMAL or ABNORMAL. Flagged results go to radiologist review.",
|
43 |
+
examples=["images/sample1.png", "images/sample2.png"]
|
44 |
+
)
|
45 |
+
|
46 |
+
if __name__ == "__main__":
|
47 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
numpy
|
3 |
+
Pillow
|
4 |
+
tensorflow
|
5 |
+
huggingface_hub
|