Update app.py
Browse files
app.py
CHANGED
|
@@ -8,13 +8,22 @@ import torch.nn as nn
|
|
| 8 |
import cv2
|
| 9 |
from albumentations.pytorch.transforms import ToTensorV2
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
model.fc = nn.Linear(2048, 21)
|
| 15 |
-
model.load_state_dict(torch.load('resnet_best.pth'), strict=True)
|
| 16 |
model.eval()
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
st.title("My awesome ML Function")
|
| 19 |
|
| 20 |
uploaded_file = st.file_uploader("Choose a file")
|
|
|
|
| 8 |
import cv2
|
| 9 |
from albumentations.pytorch.transforms import ToTensorV2
|
| 10 |
|
| 11 |
+
id2class = {0: 'agricultural', 1: 'airplane', 2: 'baseballdiamond', 3: 'beach', 4: 'buildings', 5: 'chaparral', 6: 'denseresidential', 7: 'forest', 8: 'freeway', 9: 'golfcourse', 10: 'intersection', 11: 'mediumresidential', 12: 'mobilehomepark', 13: 'overpass', 14: 'parkinglot', 15: 'river', 16: 'runway', 17: 'sparseresidential', 18: 'storagetanks', 19: 'tenniscourt', 20: 'harbor'}
|
| 12 |
+
|
| 13 |
+
model = models.resnet50(weights=None)
|
| 14 |
model.fc = nn.Linear(2048, 21)
|
| 15 |
+
model.load_state_dict(torch.load('resnet_best.pth', map_location=torch.device('cpu')), strict=True)
|
| 16 |
model.eval()
|
| 17 |
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
#Load model torch.load.state_dict(PATH)
|
| 21 |
+
#model = torch.load.state_dict('resnet_best.pth')
|
| 22 |
+
#model = models.resnet50(pretrained=False)
|
| 23 |
+
#model.fc = nn.Linear(2048, 21)
|
| 24 |
+
#model.load_state_dict(torch.load('resnet_best.pth'), strict=True)#load weights from training run
|
| 25 |
+
#model.eval()
|
| 26 |
+
|
| 27 |
st.title("My awesome ML Function")
|
| 28 |
|
| 29 |
uploaded_file = st.file_uploader("Choose a file")
|