We are trying to use fast.ai in production. Because of the many dependencies, we want to convert a learner object into a pytorch model. The learner object has an attribute model, so normally this should be quite straightforward.
test_transforms = transforms.Compose([transforms.Resize(224),
transforms.ToTensor()
])
def predict_image(image):
image_tensor = test_transforms(image).float()
image_tensor = image_tensor.unsqueeze_(0)
input = Variable(image_tensor)
input = input.to(‘cuda’)
output = learn.model(input)
return output
However, the output is not the same as the output of learn.predict(). We are using the DynamicUnet model of Lesson 3. Thanks a lot!