Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- .gitattributes +35 -35
- README.md +13 -13
- app.py +62 -0
- best_model_efficientnet_b0.pth +3 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz 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
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz 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
|
README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
---
|
2 |
-
title: Kidneystone Detection
|
3 |
-
emoji: π
|
4 |
-
colorFrom: green
|
5 |
-
colorTo: purple
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 4.29.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 |
+
---
|
2 |
+
title: Kidneystone Detection
|
3 |
+
emoji: π
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: purple
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.29.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
|
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import torch.nn as nn
|
3 |
+
from efficientnet_pytorch import EfficientNet
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
# Define the custom model architecture
|
9 |
+
class CustomModel(nn.Module):
|
10 |
+
def __init__(self):
|
11 |
+
super(CustomModel, self).__init__()
|
12 |
+
self.fc = nn.Linear(6, 50176)
|
13 |
+
self.fc_bn = nn.BatchNorm1d(50176)
|
14 |
+
self.pretrained_model = EfficientNet.from_pretrained('efficientnet-b0', num_classes=32)
|
15 |
+
self.classification_head = nn.Sequential(
|
16 |
+
nn.Linear(32, 1),
|
17 |
+
nn.Sigmoid()
|
18 |
+
)
|
19 |
+
|
20 |
+
def forward(self, x):
|
21 |
+
x = self.fc(x)
|
22 |
+
x = self.fc_bn(x)
|
23 |
+
x = x.view(-1, 224, 224)
|
24 |
+
x = torch.stack([x] * 3, dim=1)
|
25 |
+
x = self.pretrained_model(x)
|
26 |
+
x = self.classification_head(x)
|
27 |
+
return x
|
28 |
+
|
29 |
+
# Load the trained model
|
30 |
+
model = CustomModel()
|
31 |
+
model.load_state_dict(torch.load('best_model_efficientnet_b0.pth'))
|
32 |
+
model.eval()
|
33 |
+
|
34 |
+
# Load the validation dataset
|
35 |
+
#val_dataset = CustomDataset('outside.csv')
|
36 |
+
#val_loader = DataLoader(val_dataset, batch_size=32, shuffle=False)
|
37 |
+
|
38 |
+
# Function to make prediction
|
39 |
+
def predict(feature1, feature2, feature3, feature4, feature5, feature6):
|
40 |
+
features = torch.tensor([[feature1, feature2, feature3, feature4, feature5, feature6]], dtype=torch.float32)
|
41 |
+
output = model(features)
|
42 |
+
prediction = output.round().item()
|
43 |
+
return "Kidney Stone Detected" if prediction == 1 else "No Stone Detected"
|
44 |
+
light_blue = "#ADD8E6"
|
45 |
+
# Create a Gradio interface
|
46 |
+
inputs = [
|
47 |
+
gr.Slider(minimum=0.8, maximum=1.5, label="gravity: Specific Gravity"), # Using gr.Slider for each feature
|
48 |
+
gr.Slider(minimum=3, maximum=8, label="ph: pH (Potential of Hydrogen)"),
|
49 |
+
gr.Slider(minimum=200, maximum=1200, label="osmo: Osmolality"),
|
50 |
+
gr.Slider(minimum=5, maximum=30, label="cond: Conductivity"),
|
51 |
+
gr.Slider(minimum=50, maximum=700, label="urea: Urea"),
|
52 |
+
gr.Slider(minimum=0, maximum=20, label="calc: Calcium")
|
53 |
+
]
|
54 |
+
|
55 |
+
output = gr.Label() # Output label for the prediction
|
56 |
+
|
57 |
+
interface = gr.Interface(predict, inputs, output, title="Kidney Stone Detection NOTE- FOR RESEARCH PURPOSE ONLY-",
|
58 |
+
description="Enter the values for each feature",
|
59 |
+
css=f".gradio-container {{ background-color: {light_blue} }}" # Inline CSS injection
|
60 |
+
) # Customize interface details
|
61 |
+
|
62 |
+
interface.launch() # Launch the Gradio interface
|
best_model_efficientnet_b0.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a8d9e0eeee8151f9a7da88b9662f5c0bb41a1595a682ec3ac777c68de74a0f46
|
3 |
+
size 18709823
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
torchvision
|
3 |
+
efficientnet_pytorch
|
4 |
+
pandas
|
5 |
+
scikit-learn
|
6 |
+
gradio
|