Spaces:
Build error
Build error
shyamgupta196
commited on
Commit
·
2de1e53
1
Parent(s):
eeb2b1a
trans on
Browse files
app.py
CHANGED
@@ -33,17 +33,19 @@ model = model.to('cpu')
|
|
33 |
|
34 |
|
35 |
transform = transforms.Compose(
|
36 |
-
[transforms.
|
37 |
)
|
38 |
|
39 |
|
40 |
|
41 |
def predict(img):
|
42 |
-
|
43 |
# img = transform(img).unsqueeze(0)
|
44 |
with torch.no_grad():
|
45 |
out= model(img)
|
46 |
probability = torch.nn.functional.softmax(out[0],dim=0)
|
|
|
|
|
47 |
|
48 |
values, indices = torch.topk(probability,k=2)
|
49 |
return {LABELS[i]: v.item() for i,v in zip(indices,values)}
|
|
|
33 |
|
34 |
|
35 |
transform = transforms.Compose(
|
36 |
+
[transforms.Resize((128, 128)), transforms.ToTensor()]
|
37 |
)
|
38 |
|
39 |
|
40 |
|
41 |
def predict(img):
|
42 |
+
img = transform(img).to('cpu')
|
43 |
# img = transform(img).unsqueeze(0)
|
44 |
with torch.no_grad():
|
45 |
out= model(img)
|
46 |
probability = torch.nn.functional.softmax(out[0],dim=0)
|
47 |
+
print(out)
|
48 |
+
print(type(img))
|
49 |
|
50 |
values, indices = torch.topk(probability,k=2)
|
51 |
return {LABELS[i]: v.item() for i,v in zip(indices,values)}
|