我正在尝试使用 fast.ai 从我的谷歌驱动器帐户加载谷歌 colab 中的数据集。我正在使用来自 kaggle 的外星人和捕食者作为数据集,从这里 我下载并加载到我的谷歌驱动器中。然后我运行这段代码:
# Load the Drive helper and mount
from google.colab import drive
drive.mount("/content/drive")
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai import *
from fastai.vision import *
path='/content/drive/My Drive/FastaiData/Alien-vs-Predator'
tfms = get_transforms(do_flip=False)
#default bs=64, set image size=100 to run successfully on colab
data = ImageDataBunch.from_folder(path,ds_tfms=tfms, size=100)
path='/content/drive/My Drive/FastaiData/Alien-vs-Predator'
tfms = get_transforms(do_flip=False)
#default bs=64, set image size=100 to run successfully on colab
data = ImageDataBunch.from_folder(path,ds_tfms=tfms, size=100)
然后我得到了这个错误:
/usr/local/lib/python3.6/dist-packages/fastai/data_block.py:399: UserWarning: Your training set is empty. Is this is by design, pass `ignore_empty=True` to remove this warning.
warn("Your training set is empty. Is this is by design, pass `ignore_empty=True` to remove this warning.")
/usr/local/lib/python3.6/dist-packages/fastai/data_block.py:402: UserWarning: Your validation set is empty. Is this is by design, use `no_split()`
or pass `ignore_empty=True` when labelling to remove this warning.
or pass `ignore_empty=True` when labelling to remove this warning.""")
IndexError Traceback (most recent call last)
<ipython-input-3-5b3f66a4d360> in <module>()
4
5 #default bs=64, set image size=100 to run successfully on colab
----> 6 data = ImageDataBunch.from_folder(path,ds_tfms=tfms, size=100)
7
8 data.show_batch(rows=3, figsize=(10,10))
/usr/local/lib/python3.6/dist-packages/fastai/vision/data.py in from_folder(cls, path, train, valid, valid_pct, classes, **kwargs)
118 if valid_pct is None: src = il.split_by_folder(train=train, valid=valid)
119 else: src = il.random_split_by_pct(valid_pct)
--> 120 src = src.label_from_folder(classes=classes)
121 return cls.create_from_ll(src, **kwargs)
122
and so on...
它似乎发现我指示为火车和验证集的文件夹是空的,这是不正确的。
谢谢您的帮助