djairbee5 commited on
Commit
59b0a85
β€’
1 Parent(s): 2a995e9
app.py CHANGED
@@ -19,18 +19,18 @@ def load_class_info(file_path):
19
  return class_info
20
 
21
  # Function to load the model from a .pkl file
22
- def load_model(model_path, model_type='resnet'):
23
  # Load the model state dictionary
24
  model_state_dict = torch.load(model_path, map_location=torch.device('cpu'))
25
 
26
  # Create an instance of the model based on model_type
27
- if model_type == 'mobilenet':
28
  model = models.mobilenet_v2(pretrained=False)
29
  model.classifier[1] = nn.Linear(model.last_channel, num_classes)
30
- elif model_type == 'resnet':
31
- model = models.resnet50(pretrained=False)
32
  model.fc = nn.Linear(model.fc.in_features, num_classes)
33
- elif model_type == 'densenet':
34
  model = models.densenet121(pretrained=False)
35
  model.classifier = nn.Linear(model.classifier.in_features, num_classes)
36
  else:
@@ -77,7 +77,7 @@ def predict_image(image):
77
  return result, html_result
78
 
79
  # Load trained model and class names
80
- model_path = 'resnet30EpochsPretrainedNFeatureX_model.pkl'
81
  class_file_path = 'classes.txt'
82
  class_info_path = 'classinfo.txt'
83
  class_names = load_class_names(class_file_path)
 
19
  return class_info
20
 
21
  # Function to load the model from a .pkl file
22
+ def load_model(model_path, model_type='densnet121'):
23
  # Load the model state dictionary
24
  model_state_dict = torch.load(model_path, map_location=torch.device('cpu'))
25
 
26
  # Create an instance of the model based on model_type
27
+ if model_type == 'mobilenetv2':
28
  model = models.mobilenet_v2(pretrained=False)
29
  model.classifier[1] = nn.Linear(model.last_channel, num_classes)
30
+ elif model_type == 'resnet18':
31
+ model = models.resnet18(pretrained=False)
32
  model.fc = nn.Linear(model.fc.in_features, num_classes)
33
+ elif model_type == 'densenet121':
34
  model = models.densenet121(pretrained=False)
35
  model.classifier = nn.Linear(model.classifier.in_features, num_classes)
36
  else:
 
77
  return result, html_result
78
 
79
  # Load trained model and class names
80
+ model_path = 'densenet121_15EpochsPretrainedNoExtractionNoLR_model'
81
  class_file_path = 'classes.txt'
82
  class_info_path = 'classinfo.txt'
83
  class_names = load_class_names(class_file_path)
densenet30EpochsPretrainedNFeatureX_model.pkl β†’ densenet121_15EpochsPretrainedNoExtractionNoLR_model.pkl RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:66c1769d7f5c4415d6f6f7827b74b8730036271d759f98b0a8eb489849434d11
3
- size 28813477
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3a9352714d429d04123ea18b7020183130532f88ea6cc29fb26345b6b67dd27
3
+ size 28821560
densenet_model.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d696bf91d6a183c86506ca219773f7da6269197bb0d65595adf91967d9923bec
3
- size 28793666
 
 
 
 
mobilenet30EpochsPretrainedNFeatureX_model.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:506ae238566267e277c4d952cacf6da4b87f827e7f30c7302b423809a5c0047c
3
- size 9612161
 
 
 
 
mobilenet_model.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f9c3bf194d2881524678e93765fe3eec4396a599171da319620d2f9684f2a174
3
- size 9602989
 
 
 
 
resnet30EpochsPretrainedNFeatureX_model.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:edf0def0a33c6cd61025b08ee9a6256238bc26c0871c2488a7519b46c58918b3
3
- size 95097345
 
 
 
 
resnet_model.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:86c353d53e84464dd0f6114ed592aa71a77461bad5a7d28d39910f1f2f088446
3
- size 95088523