Dave-A commited on
Commit
cfd4aae
·
1 Parent(s): b3d21c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -24,6 +24,8 @@ import albumentations as A # Albumentations is a computer vision tool that boost
24
  #import seaborn as sns
25
  from albumentations.pytorch.transforms import ToTensorV2
26
 
 
 
27
  model = models.resnet50(pretrained=False)
28
  model.fc = nn.Linear(2048, 21)
29
  model.load_state_dict(torch.load('resnet_best.pth', map_location=torch.device('cpu')), strict=True)
@@ -45,6 +47,7 @@ if uploaded_file is not None:
45
 
46
  custom_pred = model.forward(tensor).detach().numpy()
47
  custom_pred
 
48
 
49
  elif ".csv" in uploaded_file.name:
50
  dataframe = pd.read_csv(uploaded_file)
 
24
  #import seaborn as sns
25
  from albumentations.pytorch.transforms import ToTensorV2
26
 
27
+ 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'}
28
+
29
  model = models.resnet50(pretrained=False)
30
  model.fc = nn.Linear(2048, 21)
31
  model.load_state_dict(torch.load('resnet_best.pth', map_location=torch.device('cpu')), strict=True)
 
47
 
48
  custom_pred = model.forward(tensor).detach().numpy()
49
  custom_pred
50
+ id2class[np.argmax(custom_pred)]
51
 
52
  elif ".csv" in uploaded_file.name:
53
  dataframe = pd.read_csv(uploaded_file)