Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,7 +147,7 @@ for key in list(state_dict.keys()):
|
|
| 147 |
|
| 148 |
model.load_state_dict(state_dict)
|
| 149 |
model.eval()
|
| 150 |
-
|
| 151 |
class_names = {
|
| 152 |
'akk': 'Actinic Keratosis',
|
| 153 |
'bcc': 'Basal Cell Carcinoma',
|
|
@@ -157,11 +157,14 @@ class_names = {
|
|
| 157 |
'nv': 'Melanocytic Nevi',
|
| 158 |
'vasc': 'Vascular Lesion'
|
| 159 |
}
|
| 160 |
-
|
|
|
|
|
|
|
| 161 |
examples_dir = "sample"
|
| 162 |
|
| 163 |
|
| 164 |
|
|
|
|
| 165 |
transformation_pipeline = transforms.Compose([
|
| 166 |
transforms.ToPILImage(),
|
| 167 |
transforms.Grayscale(num_output_channels=3),
|
|
@@ -217,7 +220,7 @@ def image_classifier(inp):
|
|
| 217 |
# postprocess
|
| 218 |
result = torch.nn.functional.softmax(result, dim=1) # apply softmax
|
| 219 |
result = result[0].detach().numpy().tolist() # take the first batch
|
| 220 |
-
labeled_result = {
|
| 221 |
|
| 222 |
return labeled_result
|
| 223 |
|
|
|
|
| 147 |
|
| 148 |
model.load_state_dict(state_dict)
|
| 149 |
model.eval()
|
| 150 |
+
"""
|
| 151 |
class_names = {
|
| 152 |
'akk': 'Actinic Keratosis',
|
| 153 |
'bcc': 'Basal Cell Carcinoma',
|
|
|
|
| 157 |
'nv': 'Melanocytic Nevi',
|
| 158 |
'vasc': 'Vascular Lesion'
|
| 159 |
}
|
| 160 |
+
"""
|
| 161 |
+
class_names = ['akk', 'bcc', 'bkl', 'df', 'mel', 'nv', 'vasc']
|
| 162 |
+
class_names.sort()
|
| 163 |
examples_dir = "sample"
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
+
|
| 168 |
transformation_pipeline = transforms.Compose([
|
| 169 |
transforms.ToPILImage(),
|
| 170 |
transforms.Grayscale(num_output_channels=3),
|
|
|
|
| 220 |
# postprocess
|
| 221 |
result = torch.nn.functional.softmax(result, dim=1) # apply softmax
|
| 222 |
result = result[0].detach().numpy().tolist() # take the first batch
|
| 223 |
+
labeled_result = {name:score for name, score in zip(class_names, result)}
|
| 224 |
|
| 225 |
return labeled_result
|
| 226 |
|