如何解决将自定义数据集与 fastai 一起使用时出错
错误:
Exception: Can't infer the type of your targets.
It's either because your data source is empty or because your labeling function raised an error.
代码:
from fastai import *
from fastai.vision import *
class URL:
MURDERHORNETS = f"https://superdata.quinniboi10.repl.co/MurderHornetimages"
path = untar_data(URL.MURDERHORNETS)
'''
path = untar_data(URLs.PETS)
files = get_image_files(path)
import PIL
img = PIL.Image.open(files[0])
img
'''
fnames = get_image_files(path)
fnames[:5]
np.random.seed (2)
pat = r'/([^/]+)_\d+\.(png|jpg|jpeg)$'
data = ImageDataBunch.from_folder(path,train=path,test=None,valid_pct=0.2,ds_tfms=get_transforms(),size=160)
data.normalize (imagenet_stats)
data.show_batch(rows=3,figsize=(7,6))
print (data.classes)
len (data.classes),data.c
learn = cnn_learner(data,models.resnet50,metrics=error_rate)
learn.fit_one_cycle(5)
learn.save ('stage-1')
数据集is here,don't comment on the name,I don't know why that is what I chose :/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。