DenseInferenceWrapper icon indicating copy to clipboard operation
DenseInferenceWrapper copied to clipboard

python3 support ?

Open krish567 opened this issue 7 years ago • 3 comments

The following error is coming when trying to use denseinference in python3:

File "/usr/local/lib/python3.5/dist-packages/denseinference/CRFProcessor.py", line 8, in <module> from denseinference.lib import dense_inference as di

ImportError: dynamic module does not define module export function (PyInit_dense_inference)

Please help me solve this problem. Thanks.

krish567 avatar May 11 '17 13:05 krish567

Python 3 is not supported at the moment.

mbickel avatar May 11 '17 13:05 mbickel

When can we expect please?

krish567 avatar May 11 '17 16:05 krish567

You can very easily port this to pytho-3, all you need to run boost with the correct python_verdsion flags. Following are the steps to do it:

Install python 3.5 :

sudo apt-get install python3-dev

Make sure you have the libboost-python-dev libraries installed:

sudo apt-get install libboost-python-dev

Download the lastest version of Boost from http://www.boost.org/

Run bootstrap with correct flags :

./bootstrap.sh --with-python=python3.5

Compile Boost in directory :

./b2

Update the Makefile to take the new boost locations(sharing my makefile)


CC	= g++
CFLAGS	= -W -Wall -O2 -DNDEBUG
#CFLAGS	= -W -Wall -g
LIB_ROOT = denseinference/lib/

all: 
	make -C clean
	make -C python

clean:
	rm -f *.a
	rm -f *.o
	rm -f *.so

libDenseCRF.a: libDenseCRF/bipartitedensecrf.cpp libDenseCRF/densecrf.cpp libDenseCRF/filter.cpp libDenseCRF/permutohedral.cpp libDenseCRF/util.cpp libDenseCRF/densecrf.h libDenseCRF/fastmath.h libDenseCRF/permutohedral.h libDenseCRF/sse_defs.h libDenseCRF/util.h
	$(CC) -fPIC libDenseCRF/bipartitedensecrf.cpp libDenseCRF/densecrf.cpp libDenseCRF/filter.cpp libDenseCRF/permutohedral.cpp libDenseCRF/util.cpp -c $(CFLAGS) -DNDEBUG
	ar rcs libDenseCRF.a bipartitedensecrf.o densecrf.o filter.o permutohedral.o util.o
	
dense_inference.so: dense_inference.o libDenseCRF.a
	$(CC) -shared -I/usr/include/python3.5m -Wl,-no-undefined -o dense_inference.so dense_inference.o -lboost_python-py35 -lpython3.5m -L. -lDenseCRF $(CFLAGS)
	
dense_inference.o: refine_3d/dense_inference.cpp refine_3d/dense_inference.h libDenseCRF.a
	$(CC) -c -fPIC -I/usr/include/python3.5m refine_3d/dense_inference.cpp -o dense_inference.o $(CFLAGS) -lDenseCRF $(CFLAGS)
	
python: dense_inference.o dense_inference.so libDenseCRF.a

.PHONY: default clean

Continue with the installation. Now you will be good to go with python3.

Hope this works for you @krish567

iabhi7 avatar Dec 22 '17 12:12 iabhi7