I have added a function to my program that uses scikit-learn’s K-Means to get the main color, but after using it several times (about 50 times) in a row, I seem to get a memory related error.
If anyone knows how to fix this error, please let me know.
Version.
- Streamlit 1.21.0
- scikit-learn 1.2.2
Relevant code
def getMainColor(self, img, color, iter):.
img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)
img = img.reshape(
(img.shape[0] * img.shape[1], 3))
cluster = KMeans(n_clusters=color, max_iter=iter)
cluster.fit(X=img)
cluster_centers_arr = cluster.cluster_centers_.astype(
int, copy=False)
hexlist = []
for rgb_arr in cluster_centers_arr:.
hexlist.append('#%02x%02x%02x' % tuple(rgb_arr))
return hexlist
Corresponding error
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
OOOOOOOOOOOOOOOOOOOOOOOpOpppppeppnppBppLAppeppnpBpLpAepnpBpLApS : Program is Terminated. Because you tried to allocaenBLAS : Program is Terminated. Because you tried to allocate too many memory regions.
This library was built to support a maximum of enBLAS :enBLAeneneteeeS : Pre Program is Terminated. enBLAS : Program is Terminated. Because you tried to allocate too many memory regions.
This library was built to support a maximum of 50 threads - either rebuild OpenBLAS
with a larger S : Program is Terminated. Because you tried to allocate too many memory regions.
This library was built to support a maximum of 50 threads - either rebuild OpenBLAS
with a larger NUM_THREADS value or set the environment variable OPENBLAS_NUM_THREADS to
a sufficiently small number. This error typically occurs when the softwareenBS : Program is Terminated. Because you tried to allocatnBLAS : Program is Terme too many memenBLAS : Program is Terminated. Because yoenBLAS : Program is Terminated. Because you tried to allocate too many memory regions.
This library was built to support a maximum of 50 threads - either rebuild OpenBLAS
with a larger NUM_THREADS value or set the environment variable OPENBLAS_NUM_THREADS to
a sufficiently small number. This error typically occurs when the software that relies on
OpenBLAS calls BLAS functions from many threads in parallel, or when your computer has more
cpu cores than what OpenBLAS was configured to handle.
enBLAS : Pory nnip eeeNonBe5uLerBBneSegmentation fault