Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,6 +48,7 @@ DesignModernityModel = torch.load("DesignModernityModel.pt")
|
|
| 48 |
DesignModernityModel.eval() # set state of the model to inference
|
| 49 |
|
| 50 |
LABELS = ['2000-2004', '2006-2008', '2009-2011', '2012-2015', '2016-2018']
|
|
|
|
| 51 |
|
| 52 |
MEAN = [0.485, 0.456, 0.406]
|
| 53 |
STD = [0.229, 0.224, 0.225]
|
|
@@ -61,7 +62,7 @@ def classifyCar(im):
|
|
| 61 |
im = carTransforms(im).unsqueeze(0) # transform and add batch dimension
|
| 62 |
with torch.no_grad():
|
| 63 |
scores = torch.nn.functional.softmax(DesignModernityModel(im)[0])
|
| 64 |
-
return {LABELS[i]: float(scores[i]) for i in range(
|
| 65 |
|
| 66 |
#examples = [[example_img.jpg], [example_img2.jpg]] # must be uploaded in repo
|
| 67 |
|
|
|
|
| 48 |
DesignModernityModel.eval() # set state of the model to inference
|
| 49 |
|
| 50 |
LABELS = ['2000-2004', '2006-2008', '2009-2011', '2012-2015', '2016-2018']
|
| 51 |
+
n_labels = len(LABELS)
|
| 52 |
|
| 53 |
MEAN = [0.485, 0.456, 0.406]
|
| 54 |
STD = [0.229, 0.224, 0.225]
|
|
|
|
| 62 |
im = carTransforms(im).unsqueeze(0) # transform and add batch dimension
|
| 63 |
with torch.no_grad():
|
| 64 |
scores = torch.nn.functional.softmax(DesignModernityModel(im)[0])
|
| 65 |
+
return {LABELS[i]: float(scores[i]) for i in range(n_labels)}
|
| 66 |
|
| 67 |
#examples = [[example_img.jpg], [example_img2.jpg]] # must be uploaded in repo
|
| 68 |
|