Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -148,7 +148,7 @@ def predict(img_path):
|
|
| 148 |
|
| 149 |
# Move the model to CPU and load its state dict from the specified path
|
| 150 |
inf_model.to(torch.device('cpu'))
|
| 151 |
-
inf_model.load_state_dict(torch.load('
|
| 152 |
|
| 153 |
# Perform inference on the image using the model
|
| 154 |
with torch.no_grad():
|
|
@@ -166,7 +166,7 @@ def predict(img_path):
|
|
| 166 |
confidence = probabilities[0, idx].item() * 100 # Get confidence for the predicted class
|
| 167 |
|
| 168 |
# Read nutrition data from a CSV file and match the predicted class
|
| 169 |
-
nutrition_data_path = '
|
| 170 |
df = pd.read_csv(nutrition_data_path)
|
| 171 |
|
| 172 |
if pred_class.capitalize() in df["Makanan"].values:
|
|
|
|
| 148 |
|
| 149 |
# Move the model to CPU and load its state dict from the specified path
|
| 150 |
inf_model.to(torch.device('cpu'))
|
| 151 |
+
inf_model.load_state_dict(torch.load('./resnet18_tinyfood_classifier.pth', map_location='cpu'))
|
| 152 |
|
| 153 |
# Perform inference on the image using the model
|
| 154 |
with torch.no_grad():
|
|
|
|
| 166 |
confidence = probabilities[0, idx].item() * 100 # Get confidence for the predicted class
|
| 167 |
|
| 168 |
# Read nutrition data from a CSV file and match the predicted class
|
| 169 |
+
nutrition_data_path = './food-data.csv'
|
| 170 |
df = pd.read_csv(nutrition_data_path)
|
| 171 |
|
| 172 |
if pred_class.capitalize() in df["Makanan"].values:
|