0

在 jupyter notebook 中运行 Roboflow 图像分类的代码时,我和我的团队不断收到相同的错误。

如果有人可以帮助我们更好地理解这个错误的含义以及为什么我们不断得到它,那将不胜感激!

这是代码:

data = ImageDataLoaders.from_folder(path, size=220, num_workers=4).normalize(imagenet_stats)

这是错误:

AttributeError                            Traceback (most recent call last)
/var/folders/mf/sm4q6hh96j5bq3f327w8px0m0000gn/T/ipykernel_42187/1206335196.py in <module>
----> 1 data = ImageDataLoaders.from_folder(path, size=220, num_workers=4).normalize(imagenet_stats)

~/opt/anaconda3/envs/pytorch1/lib/python3.7/site-packages/fastcore/basics.py in __getattr__(self, k)
    387         if self._component_attr_filter(k):
    388             attr = getattr(self,self._default,None)
--> 389             if attr is not None: return getattr(attr,k)
    390         raise AttributeError(k)
    391     def __dir__(self): return custom_dir(self,self._dir())

~/opt/anaconda3/envs/pytorch1/lib/python3.7/site-packages/fastcore/basics.py in __getattr__(self, k)
    387         if self._component_attr_filter(k):
    388             attr = getattr(self,self._default,None)
--> 389             if attr is not None: return getattr(attr,k)
    390         raise AttributeError(k)
    391     def __dir__(self): return custom_dir(self,self._dir())

~/opt/anaconda3/envs/pytorch1/lib/python3.7/site-packages/fastai/data/core.py in __getattr__(self, k)
    333         return res if is_indexer(it) else list(zip(*res))
    334 
--> 335     def __getattr__(self,k): return gather_attrs(self, k, 'tls')
    336     def __dir__(self): return super().__dir__() + gather_attr_names(self, 'tls')
    337     def __len__(self): return len(self.tls[0])

~/opt/anaconda3/envs/pytorch1/lib/python3.7/site-packages/fastcore/transform.py in gather_attrs(o, k, nm)
    163     att = getattr(o,nm)
    164     res = [t for t in att.attrgot(k) if t is not None]
--> 165     if not res: raise AttributeError(k)
    166     return res[0] if len(res)==1 else L(res)
    167 

AttributeError: normalize```
4

1 回答 1

0

这不是 Roboflow 错误响应,它是在属性引用或分配失败时发生的 Python 错误响应。

示例:分配x=10然后尝试x.append()将引发 AttributeError,因为该变量是整数类型,它不支持 append 方法。

我将首先查看您尝试规范化的数据类型,并查看.normalize()该数据类型是否支持

于 2022-03-04T12:12:34.443 回答