Thanks for the idea, but it didn’t work. I added :
import torch.nn as nn
to both .ipynb files and it still will not run on the index. I can copy and paste the whole function into the index notebook, but that seems to defeat the purpose right?
so fastai apparently already needs torch to be loaded which is why nn.Cosin… works in the movie_recommender.ipynb file. I tried your pip install but this(below) happpend and it still throws the error: 'nn' is not defined
@daveramseymusic Hey, you are not exporting your imports. In particular, when you check movie-recommender/movie-recommender.py you can see that it doesnt import anything, so it can not know of nn. Add #| export to the top of
# For modeling
from fastai.tabular.all import *
from fastai.collab import *
#for publishing the model
import gradio as gr
and it should solve your problem
Edit: Great project btw, it picked my movie for tonight
Update: I fixed the error: “name ‘learn’ is not defined” by adding #| export to the learn=load_learner(path/'movie_predictor_large20mil_639.pkl') cell.
I was having difficulty running nbdev_prepare because the README was not in the nbs directory.
I fixed it using this code where I loaded the learn and titles:
#| export
#load the model and movie titles with indexes (from the previous data loaders)
path = Path('.')
data_folder = '../models_and_dls'
#check if modedels folder is up one level if not 'for readme' then check in current directory
if not os.path.isdir(data_folder):
data_folder = './models_and_dls'
#load learner and titles csv
learn = load_learner(path/data_folder/'movie_predictor_large20mil_xtrau_624.pkl')
titles = pd.read_csv(path/data_folder/'movie_20mil_xtrau_dls.csv')