Spaces:
Runtime error
Runtime error
added cpu shift code again
Browse files
app.py
CHANGED
@@ -10,6 +10,15 @@ from PIL import Image
|
|
10 |
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Defining our Class for just prediction
|
14 |
def accuracy(outputs, labels):
|
15 |
_, preds = torch.max(outputs, dim=1)
|
@@ -60,7 +69,8 @@ classes = ['burger', 'butter_naan', 'chai', 'chapati', 'chole_bhature',
|
|
60 |
'kaathi_rolls', 'kadai_paneer', 'kulfi', 'masala_dosa', 'momos',
|
61 |
'paani_puri', 'pakode', 'pav_bhaji', 'pizza', 'samosa']
|
62 |
model = IndianFoodModelResnet50(len(classes), pretrained=True)
|
63 |
-
|
|
|
64 |
|
65 |
|
66 |
# Loading the model
|
|
|
10 |
|
11 |
|
12 |
|
13 |
+
# Moving data to CPU
|
14 |
+
def to_device(data, device):
|
15 |
+
"""Move tensor(s) to chosen device"""
|
16 |
+
if isinstance(data, (list,tuple)):
|
17 |
+
return [to_device(x, device) for x in data]
|
18 |
+
return data.to(device, non_blocking=True)
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
# Defining our Class for just prediction
|
23 |
def accuracy(outputs, labels):
|
24 |
_, preds = torch.max(outputs, dim=1)
|
|
|
69 |
'kaathi_rolls', 'kadai_paneer', 'kulfi', 'masala_dosa', 'momos',
|
70 |
'paani_puri', 'pakode', 'pav_bhaji', 'pizza', 'samosa']
|
71 |
model = IndianFoodModelResnet50(len(classes), pretrained=True)
|
72 |
+
device = 'cpu'
|
73 |
+
to_device(model, device);
|
74 |
|
75 |
|
76 |
# Loading the model
|