Spaces:
Sleeping
Sleeping
new model
Browse files- app.py +6 -6
- densenet30EpochsPretrainedNFeatureX_model.pkl β densenet121_15EpochsPretrainedNoExtractionNoLR_model.pkl +2 -2
- densenet_model.pkl +0 -3
- mobilenet30EpochsPretrainedNFeatureX_model.pkl +0 -3
- mobilenet_model.pkl +0 -3
- resnet30EpochsPretrainedNFeatureX_model.pkl +0 -3
- resnet_model.pkl +0 -3
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='
|
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 == '
|
28 |
model = models.mobilenet_v2(pretrained=False)
|
29 |
model.classifier[1] = nn.Linear(model.last_channel, num_classes)
|
30 |
-
elif model_type == '
|
31 |
-
model = models.
|
32 |
model.fc = nn.Linear(model.fc.in_features, num_classes)
|
33 |
-
elif model_type == '
|
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 = '
|
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:
|
3 |
-
size
|
|
|
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
|
|
|
|
|
|
|
|