Spaces:
Sleeping
Sleeping
Commit
·
00c3ab6
1
Parent(s):
26eaf37
finish app
Browse files- Dockerfile +2 -1
- src/modelOps.py +3 -2
- src/streamlit_app.py +1 -1
Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
FROM python:3.
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
@@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y \
|
|
9 |
git \
|
10 |
&& rm -rf /var/lib/apt/lists/*
|
11 |
|
|
|
12 |
COPY requirements.txt ./
|
13 |
COPY src/ ./src/
|
14 |
|
|
|
1 |
+
FROM python:3.11-slim
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
|
|
9 |
git \
|
10 |
&& rm -rf /var/lib/apt/lists/*
|
11 |
|
12 |
+
RUN pip3 install wheel
|
13 |
COPY requirements.txt ./
|
14 |
COPY src/ ./src/
|
15 |
|
src/modelOps.py
CHANGED
@@ -4,11 +4,12 @@ import torch
|
|
4 |
from torch import nn
|
5 |
from PIL import Image
|
6 |
from pathlib import Path
|
|
|
7 |
|
8 |
# 1. Load Model
|
9 |
@st.cache_resource
|
10 |
-
def load_model(MODEL_PATH: Path = "src/outputs/p2_e29_best_model.pth", device: str = "cpu"):
|
11 |
-
model = models.mobilenet_v2(
|
12 |
model.classifier[1] = nn.Linear(model.classifier[1].in_features, 10)
|
13 |
|
14 |
state_dict = torch.load(MODEL_PATH, map_location=device)
|
|
|
4 |
from torch import nn
|
5 |
from PIL import Image
|
6 |
from pathlib import Path
|
7 |
+
from torchvision.models import MobileNet_V2_Weights
|
8 |
|
9 |
# 1. Load Model
|
10 |
@st.cache_resource
|
11 |
+
def load_model(MODEL_PATH: Path = Path("src/outputs/p2_e29_best_model.pth"), device: str = "cpu"):
|
12 |
+
model = models.mobilenet_v2(weights=MobileNet_V2_Weights.DEFAULT)
|
13 |
model.classifier[1] = nn.Linear(model.classifier[1].in_features, 10)
|
14 |
|
15 |
state_dict = torch.load(MODEL_PATH, map_location=device)
|
src/streamlit_app.py
CHANGED
@@ -11,7 +11,7 @@ def main():
|
|
11 |
st.write("Upload an X-ray image to classify potential fractures.")
|
12 |
|
13 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
14 |
-
model = load_model(device)
|
15 |
|
16 |
uploaded_file = st.file_uploader("Upload an X-ray image", type=["jpg", "jpeg", "png"])
|
17 |
|
|
|
11 |
st.write("Upload an X-ray image to classify potential fractures.")
|
12 |
|
13 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
14 |
+
model = load_model(device=device)
|
15 |
|
16 |
uploaded_file = st.file_uploader("Upload an X-ray image", type=["jpg", "jpeg", "png"])
|
17 |
|