【发布时间】:2023-02-06 22:58:52
【问题描述】:
我正在使用图像识别制作人工智能,所以我将播放的每一帧记录到一个 numpy 数组中。当我第一次导出所有图像并获得其中的 6000 张时,它工作得很好。现在,我正在记录更多的数据,但突然间我得到了这个错误,而我的代码或环境没有任何变化
追溯(最近一次通话):
文件“D:\Dev\Fall-Guys-AI-Race\utils\CreateImages.py”,第 6 行,位于 > data = np.load("D:/Dev/Fall-Guys-AI-Race/data/training_data.npy", allow_pickle=True)
文件“D:\Program Files\Python39\lib\site-packages\numpy\lib\npyio.py”,第 430 行,加载中 > 返回格式.read_array(fid, allow_pickle=allow_pickle,
文件“D:\Program Files\Python39\lib\site-packages\numpy\lib\format.py”,第 786 行,在 read_array 中 > array.shape = 形状
ValueError:无法将大小为 2147483648 的数组重塑为形状 (14460,224,224,3)
这是我的 CreateImages.py :
import cv2, os import numpy as np listing = os.listdir("D:/Dev/Fall-Guys-AI-Race/data/") for j in range(1): data = np.load("D:/Dev/Fall-Guys-AI-Race/data/training_data.npy", allow_pickle=True) targets = np.load("D:/Dev/Fall-Guys-AI-Race/data/target_data.npy", allow_pickle=True) print(f'Image Data Shape: {data.shape}') print(f'targets Shape: {targets.shape}') # Lets see how many of each type of move we have. unique_elements, counts = np.unique(targets, return_counts=True) # Store both data and targets in a list. # We may want to shuffle down the road. holder_list = [] for i, image in enumerate(data): holder_list.append([data[i], targets[i]]) count_up = 0 count_left = 0 count_right = 0 count_jump = 0 count_down = 0 for data in holder_list: #writes data to image in correct folder, skipped because lots of lines: cv2.imwrite(f"*my_path*{count_left}.png", data[0]) print("done") print(count_down, count_up, count_jump, count_left, count_right)谢谢您的帮助
【问题讨论】:
标签: python numpy opencv pickle numpy-ndarray