Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,12 +12,12 @@ model.load_state_dict(state_dict)
|
|
| 12 |
model.eval()
|
| 13 |
|
| 14 |
#predictions
|
| 15 |
-
imgTransforms = transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224),
|
| 16 |
|
| 17 |
LABELS =['Fiat 500', 'VW Up']
|
| 18 |
def predict(inp):
|
| 19 |
inp= Image.fromarray(inp.astype('unit8'), 'RGB')
|
| 20 |
-
inp =
|
| 21 |
|
| 22 |
with torch.no_grad():
|
| 23 |
predictions = torch.nn.functional.softmax(model(inp)[0])
|
|
|
|
| 12 |
model.eval()
|
| 13 |
|
| 14 |
#predictions
|
| 15 |
+
imgTransforms = transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(),transforms.Normalize([0.485,0.456,0.406],[0.229,0.224,0.225])])
|
| 16 |
|
| 17 |
LABELS =['Fiat 500', 'VW Up']
|
| 18 |
def predict(inp):
|
| 19 |
inp= Image.fromarray(inp.astype('unit8'), 'RGB')
|
| 20 |
+
inp =imgTransforms(inp).unsqueeze(0)
|
| 21 |
|
| 22 |
with torch.no_grad():
|
| 23 |
predictions = torch.nn.functional.softmax(model(inp)[0])
|