Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import os
|
|
5 |
import torch.nn as nn
|
6 |
import torchvision
|
7 |
from model import create_model
|
|
|
8 |
|
9 |
from timeit import default_timer as timer
|
10 |
from typing import Tuple, Dict
|
@@ -14,7 +15,7 @@ title = 'FoodVisionMini - Diljith'
|
|
14 |
description = 'Classifies an image of food item into either one of 3 classes : pizza, steak or sushi'
|
15 |
|
16 |
effnetb2, transforms, optimizer, lossFunc = create_model(num_classes = 3)
|
17 |
-
effnetb2.load_state_dict(torch.load(f = 'effnet_b2-20%-10epochs.pth'
|
18 |
|
19 |
|
20 |
class_names = ['pizza', 'steak', 'sushi']
|
@@ -34,7 +35,7 @@ def predict(img):
|
|
34 |
return probs_dict, end-start
|
35 |
|
36 |
|
37 |
-
|
38 |
example_list = [['examples/' + example] for example in os.listdir(examples_path)]
|
39 |
|
40 |
projectApp = gr.Interface(
|
|
|
5 |
import torch.nn as nn
|
6 |
import torchvision
|
7 |
from model import create_model
|
8 |
+
from pathlib import Path
|
9 |
|
10 |
from timeit import default_timer as timer
|
11 |
from typing import Tuple, Dict
|
|
|
15 |
description = 'Classifies an image of food item into either one of 3 classes : pizza, steak or sushi'
|
16 |
|
17 |
effnetb2, transforms, optimizer, lossFunc = create_model(num_classes = 3)
|
18 |
+
effnetb2.load_state_dict(torch.load(f = 'effnet_b2-20%-10epochs.pth', map_location = torch.device('cpu')))
|
19 |
|
20 |
|
21 |
class_names = ['pizza', 'steak', 'sushi']
|
|
|
35 |
return probs_dict, end-start
|
36 |
|
37 |
|
38 |
+
examples_path = Path('examples/')
|
39 |
example_list = [['examples/' + example] for example in os.listdir(examples_path)]
|
40 |
|
41 |
projectApp = gr.Interface(
|