Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to makefile to port to Python3. Readme updated for the same #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions denseinference/lib/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# update the path variables
# update the path variables

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

all:
all:
make -C clean
make -C python

Expand All @@ -17,13 +17,20 @@ clean:
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/python2.7 -Wl,-no-undefined -o dense_inference.so dense_inference.o -lpython2.7 -lboost_python -L. -lDenseCRF $(CFLAGS)

dense_inference.o: refine_3d/dense_inference.cpp refine_3d/dense_inference.h libDenseCRF.a
$(CC) -c -fPIC -I/usr/include/python2.7 refine_3d/dense_inference.cpp -o dense_inference.o $(CFLAGS) -lDenseCRF $(CFLAGS)



# For python3 use the following \
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
.PHONY: default clean
33 changes: 32 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,35 @@ result = pro.set_data_and_run(img, feature_tensor)

- **param img**: Normalized input as ndarray. (W, H, D), [0, 1]
- **param label**: Continuous label tensor as ndarray. (W, H, D, L), [0, 1]
- **return**: Hard labeled result as ndarray. (W, H, D), [0, L], dtype=int16
- **return**: Hard labeled result as ndarray. (W, H, D), [0, L], dtype=int16


# Porting to Python3
If you want to use this in `python3` then you can follow the following steps

#### Requirements

`make, g++, boost-python3.5`

### Installation of Boost for Python3


#### 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 (Already did)