python - MEMORY ISSUE: MemoryError: Unable to allocate array with shape (4104, 1048576, 3) and data type int32
问题描述
我有一个如下所示的工作代码,但是当我的 rgbL 非常大时,我收到了这个错误:MEMORY ISSUE: MemoryError: Unable to allocate array with shape (4104, 1048576, 3) and data type int32
如何解决这个问题?
sh = img.shape
img = img.reshape(-1, 3)
img[np.where(((rgbL[:,None,:]-img)==0).all(axis=2))[1]]=np.array([255,0,0])
img = img.reshape(sh)
其中 img 和 rgbL 定义为:
img:
[[20 45 40]
[ 30 45 60]
[ 0 1 2]
[ 70 50 100]
[ 4 5 6]]
rgbL:
[[ 20, 45, 40],
[ 30, 45, 60],
..........
[ 70, 50, 100]]
解决方案
推荐阅读
- python-3.x - pyspark 将数组类型列拆分为多列
- reactjs - 我无法在 react redux 中使用 useSelector 返回数据
- cordova - 应用程序在 Payload 中引用非公共选择器确定AppInstallationAttributionWithCompletionHandler:、lookupAdConversionDetails
- python - time.sleep 函数同时返回,为什么?
- c - 为什么你必须释放 malloc 分配的内存,而不是你分配的内存来说出你声明的函数,如 int 或 bool?
- scrapy - Scrapy+Splash 返回错误的标题
- javascript - 避免在 location.href 中使用 onbeforeunload
- paypal - 我在使用沙盒帐户的 Paypal 中遇到了这个问题
- reactjs - 如何在 React Native webview 中使用 PostMessage?
- lru - 什么 LRU 变体页面替换策略处理顺序泛洪?