TypeError: pic should be PIL Image or ndarray. Got <class ‘NoneType‘>

Posted 沉迷单车的追风少年

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: pic should be PIL Image or ndarray. Got <class ‘NoneType‘>相关的知识,希望对你有一定的参考价值。

项目场景:

Alexnet分类任务


问题描述

完整报错如下:

Traceback (most recent call last):
  File "alexnet_acc.py", line 48, in <module>
    image_input = preprocess(image_cv)
  File "/root/anaconda3/envs/torch1/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 61, in __call__
    img = t(img)
  File "/root/anaconda3/envs/torch1/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/root/anaconda3/envs/torch1/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 304, in forward
    return F.resize(img, self.size, self.interpolation, self.max_size, self.antialias)
  File "/root/anaconda3/envs/torch1/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 419, in resize
    return F_pil.resize(img, size=size, interpolation=

以上是关于TypeError: pic should be PIL Image or ndarray. Got <class ‘NoneType‘>的主要内容,如果未能解决你的问题,请参考以下文章

TypeError argument should be a Buffer

Python 3 urllib 产生 TypeError: POST data should be bytes or an iterable of bytes。它不能是 str 类型

Python 读写文件 中文乱码 错误TypeError: write() argument must be str, not bytes+

TypeError: string indices must be integers, not str

FluentAssertions:ShouldBeEquivalentTo vs Should().Be() vs Should().BeEquivalentTo()?

[1.1]Knowledge that should be prepared