Hello,
I have saved my Pytorch model as a state_dict, and am now trying to load it into flask for inference.
However when I run my flask API, it just stopped. And using my debugger got me here.
The same model loads in my notebook. Why is this happening? Any help would be great!
1 Like
Hey, It doesn’t seem to be a code problem. The flask app used to work on my old system, but doesn’t on my new one. Same code in both places.
please provide more code in you utils.py
and pytorch_model.py
Sure
this is from pytorch_model.py
from torch import nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
self.linearA = nn.Linear(13,100)
self.linearB = nn.Linear(100, 50)
self.linearC = nn.Linear(50, 1)
def forward(self, x):
yA = F.relu(self.linearA(x))
yB = F.relu(self.linearB(yA))
return self.linearC(yB)
and this is the part from utils.py
data.model = Model()
data.model.load_state_dict(torch.load(data.model_path))