【问题标题】:Face-Recognition: ValueError: Object arrays cannot be loaded when allow_pickle=False人脸识别:ValueError: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

【问题讨论】:

  • 传递给函数的是什么?

标签: python tensorflow keras face-recognition valueerror


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2020-12-12
    • 2015-09-10
    • 2015-10-13
    • 2021-03-18
    • 2020-08-13
    • 2011-12-14
    • 1970-01-01
    • 2021-12-30
    • 2012-11-15
    相关资源
    最近更新 更多