lucasb-eyer / pydensecrf

Python wrapper to Philipp Krähenbühl's dense (fully connected) CRFs with gaussian edge potentials.
MIT License
1.93k stars 411 forks source link

terminate called after throwing an instance of 'std::length_error' what(): vector::_M_fill_insert Aborted (core dumped) #115

Open yaatsn3821 opened 2 years ago

yaatsn3821 commented 2 years ago

First of all, thanks a lot for packaging this! I tried this code.

import numpy as np
import pydensecrf.densecrf as dcrf
from pydensecrf.utils import unary_from_softmax, create_pairwise_bilateral

probs = np.random.rand((0,1),30000,30000)
probs = np.tile(probs[np.newaxis,:,:],(2,1,1))
probs[1,:,:] = 1 - probs[0,:,:]
U = unary_from_softmax(probs) 
img = np.zeros((30000,30000), np.uint8)
pairwise_energy = create_pairwise_bilateral(sdims=(10,10), schan=(0.01,), img=img, chdim=-1)
d = dcrf.DenseCRF2D(30000, 30000, 2)
d.setUnaryEnergy(U)
d.addPairwiseEnergy(pairwise_energy, compat=10)

but, got below error.

terminate called after throwing an instance of 'std::length_error'
  what():  vector::_M_fill_insert
Aborted (core dumped)

This is probably because img size is very large.Retried with about 10000x10000,it's no error. But, 30000x30000 size image need to be processed. Dividing image is the best solution? Could some one help me?