Exemple #1
0
def load_normalized_test_case(data_paths, mean):
    case_num = randint(0, 9)
    [test_case_path] = common.locate_files(data_paths,
                                           [str(case_num) + ".pgm"])
    # Flatten the image into a 1D array, and normalize.
    img = np.array(Image.open(test_case_path)).ravel() - mean
    return img, case_num
def load_normalized_test_case(data_paths,
                              pagelocked_buffer,
                              case_num=randint(0, 9)):
    [test_case_path] = common.locate_files(data_paths,
                                           [str(case_num) + ".pgm"])
    # Flatten the image into a 1D array, normalize, and copy to pagelocked memory.
    img = np.array(Image.open(test_case_path)).ravel()
    np.copyto(pagelocked_buffer, 1.0 - img / 255.0)
    return case_num
Exemple #3
0
def load_normalized_test_case(data_paths,
                              pagelocked_buffer,
                              case_num=randint(0, 9)):
    [test_case_path] = common.locate_files(
        data_paths, [str(case_num) + ".pgm"],
        err_msg=
        "MNIST image data not found. Please follow the README instructions.")
    # Flatten the image into a 1D array, normalize, and copy to pagelocked memory.
    img = np.array(Image.open(test_case_path)).ravel()
    np.copyto(pagelocked_buffer, 1.0 - img / 255.0)
    return case_num
Exemple #4
0
def load_normalized_test_case(data_paths,
                              pagelocked_buffer,
                              case_num=randint(0, 9)):
    [test_case_path] = common.locate_files(
        data_paths, [str(case_num) + ".pgm"],
        err_msg=
        "Please follow the README in the mnist data directory (usually in `/usr/src/tensorrt/data/mnist`) to download the MNIST dataset"
    )
    # Flatten the image into a 1D array, normalize, and copy to pagelocked memory.
    img = np.array(Image.open(test_case_path)).ravel()
    np.copyto(pagelocked_buffer, 1.0 - img / 255.0)
    return case_num
Exemple #5
0
def load_normalized_test_case(data_paths,
                              pagelocked_buffer,
                              case_num=randint(0, 9)):
    #获取相应的测试数据路径的列表
    [test_case_path] = common.locate_files(
        data_paths, [str(case_num) + ".pgm"],
        err_msg=
        "MNIST image data not found. Please follow the README instructions.")
    # Flatten the image into a 1D array, normalize, and copy to pagelocked memory.
    #ravel将图片多维数据降成一维
    img = np.array(Image.open(test_case_path)).ravel()
    #对图片数据进行归一化并且复制到指定的页面锁定内存中
    #numpy.copyto将相应的数据复制到提供的页面锁定内存中
    np.copyto(pagelocked_buffer, 1.0 - img / 255.0)
    return case_num