MarcoForte / closed-form-matting

Python implementation of A. Levin D. Lischinski and Y. Weiss. A Closed Form Solution to Natural Image Matting. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), June 2006, New York
MIT License
435 stars 107 forks source link

Test failing #24

Open NicolaGugole opened 11 months ago

NicolaGugole commented 11 months ago

Hi Marco! Really interesting repo, would like to try it using trimaps.

Unfortunately, when following your instructions I get an unclear error on your basic test:

INFO:root:Computing Matting Laplacian. Traceback (most recent call last): File "/home/wizard/mambaforge/envs/matting/bin/closed-form-matting", line 8, in sys.exit(main()) File "/home/wizard/mambaforge/envs/matting/lib/python3.5/site-packages/closed_form_matting/closed_form_matting.py", line 192, in main alpha = closed_form_matting_with_trimap(image, trimap) File "/home/wizard/mambaforge/envs/matting/lib/python3.5/site-packages/closed_form_matting/closed_form_matting.py", line 150, in closed_form_matting_with_trimap return closed_form_matting_with_prior(image, trimap, trimap_confidence consts_map, consts_map) File "/home/wizard/mambaforge/envs/matting/lib/python3.5/site-packages/closed_form_matting/closed_form_matting.py", line 133, in closed_form_matting_with_prior laplacian = compute_laplacian(image, ~consts_map if consts_map is not None else None) File "/home/wizard/mambaforge/envs/matting/lib/python3.5/site-packages/closed_form_matting/closed_form_matting.py", line 108, in compute_laplacian L = scipy.sparse.csr_matrix((nz_indsVal, nz_indsCol, np.arange(0, nz_indsVal.shape[0] + 1, win_size)), shape=(hw, h*w)) File "/home/wizard/mambaforge/envs/matting/lib/python3.5/site-packages/scipy/sparse/compressed.py", line 108, in init self.check_format(full_check=False) File "/home/wizard/mambaforge/envs/matting/lib/python3.5/site-packages/scipy/sparse/compressed.py", line 172, in check_format "".format(len(self.indptr), major_dim + 1)) ValueError: index pointer size (385039) should be (44416)

To reproduce:

git clone https://github.com/MarcoForte/closed-form-matting.git

cd closed-form-matting/

pip install .

closed-form-matting ./testdata/source.png -t ./testdata/trimap.png  -o output_alpha.png
vadimkantorov commented 10 months ago

Same error :(

vadimkantorov commented 10 months ago

I think the last commit added returning laplacian as CSR, but didn't test it: https://github.com/MarcoForte/closed-form-matting/commit/d5d8b05bc84575e52c9422e7b6ec5fdb3c0cc957

By commenting out L = scipy.sparse.csr_matrix..., the code starts working again