人脸识别:ValueError:allow_pickle=False 时无法加载对象数组

Posted

技术标签:

【中文标题】人脸识别:ValueError:allow_pickle=False 时无法加载对象数组【英文标题】:Face-Recognition: ValueError: Object arrays cannot be loaded when allow_pickle=False 【发布时间】:2021-07-30 03:41:21 【问题描述】:

Error ScreenShot

def read_array(fp, allow_pickle=False, pickle_kwargs=None):
    version = read_magic(fp)
    _check_version(version)
    shape, fortran_order, dtype = _read_array_header(fp, version)
    if len(shape) == 0:
        count = 1
    else:
        count = numpy.multiply.reduce(shape, dtype=numpy.int64)

    # Now read the actual data.
    if dtype.hasobject:
        # The array contained Python objects. We need to unpickle the data.
        **if not allow_pickle:
            raise ValueError("Object arrays cannot be loaded when "
                             "allow_pickle=False")**
        if pickle_kwargs is None:
            pickle_kwargs = 
        try:
            array = pickle.load(fp, **pickle_kwargs)
        except UnicodeError as err:
            # Friendlier error message
            raise UnicodeError("Unpickling a python object failed: %r\n"
                               "You may need to pass the encoding= option "
                               "to numpy.load" % (err,))
    else:
        if isfileobj(fp):
            # We can use the fast fromfile() function.
            array = numpy.fromfile(fp, dtype=dtype, count=count)
        else:
            array = numpy.ndarray(count, dtype=dtype)

            if dtype.itemsize > 0:
                # If dtype.itemsize == 0 then there's nothing more to read
                max_read_count = BUFFER_SIZE // min(BUFFER_SIZE, dtype.itemsize)

                for i in range(0, count, max_read_count):
                    read_count = min(max_read_count, count - i)
                    read_size = int(read_count * dtype.itemsize)
                    data = _read_bytes(fp, read_size, "array data")
                    array[i:i+read_count] = numpy.frombuffer(data, dtype=dtype,
                                                             count=read_count)

        if fortran_order:
            array.shape = shape[::-1]
            array = array.transpose()
        else:
            array.shape = shape

    return array

【问题讨论】:

传递给函数的是什么? 【参考方案1】:

您可能需要先阅读以下内容:

How to fix 'Object arrays cannot be loaded when allow_pickle=False

【讨论】:

以上是关于人脸识别:ValueError:allow_pickle=False 时无法加载对象数组的主要内容,如果未能解决你的问题,请参考以下文章

ValueError:检查目标时出错:预期activation_6 的形状为(70,)但得到的数组形状为(71,)

人脸识别技术是啥?如何进行人脸识别数据标注?

人脸识别怎么用

人脸识别sdk注册失败28677

人脸识别SDK虹软的好用吗?

人脸识别有啥用途?