FastAI:从学习者那里获得图像预测
pytorch 206
原文标题 :FastAI : Getting Prediction of Image from Learner
我希望能够从学习者那里预测单个图像的类别,并且我总是得到一个索引超出范围的异常。这是代码
data = ImageDataLoader.from_folder(path, train="Train", valid ="Valid",
ds_tfms=get_transforms(), size=(256,256), bs=32, num_workers=4)
//Model is a Sequential One
learn = Learner(data, model, loss_func = nn.CrossEntropyLoss(), metrics=accuracy)// The Model
learn.fit_one_cycle(100, lr_max=3e-3)
Img = //PIL Image Path
learn.predict(img)
该模型能够在 ImageDataLoader 上进行预测,但不能在单个图像上进行预测。如果有人有任何线索,将不胜感激这里是 FastAi 的链接,但没有解决问题 https://forums.fast.ai/t/how-to-使用学习者预测列表索引超出范围/81998/7