ErdemAtak commited on
Commit
2c421d8
·
verified ·
1 Parent(s): e37553d

Update app.py

Browse files

edited fix for fiel path

Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -6,6 +6,7 @@ import gradio as gr
6
  import os
7
  import torch
8
 
 
9
  from model import create_effnetb2_model
10
  from timeit import default_timer as timer
11
  from typing import Tuple, Dict
@@ -17,11 +18,11 @@ class_names = ['pizza', 'steak', 'sushi']
17
  effnetb2, effnetb2_transforms = create_effnetb2_model(num_classes = 3)
18
 
19
  # Load save weights
 
 
 
20
  effnetb2.load_state_dict(
21
- torch.load(
22
- f="/content/demos/foodvision_mini/09_pretrained_effnetb2_pizza_steak_sush_20_percent.pth",
23
- map_location=torch.device("cpu") # load the model to the cpu
24
- )
25
  )
26
 
27
  ### 3. Predict function ###
 
6
  import os
7
  import torch
8
 
9
+ from pathlib import Path
10
  from model import create_effnetb2_model
11
  from timeit import default_timer as timer
12
  from typing import Tuple, Dict
 
18
  effnetb2, effnetb2_transforms = create_effnetb2_model(num_classes = 3)
19
 
20
  # Load save weights
21
+ BASE_DIR = Path(__file__).resolve().parent
22
+ WEIGHTS_PATH = BASE_DIR / "09_pretrained_effnetb2_pizza_steak_sush_20_percent.pth"
23
+
24
  effnetb2.load_state_dict(
25
+ torch.load(WEIGHTS_PATH, map_location=torch.device("cpu"))
 
 
 
26
  )
27
 
28
  ### 3. Predict function ###