paddlepaddle-c++预测代码

参考GitHub:

https://github.com/yangninghua/deeplearning_backbone

makefile文件: 

CC      = gcc
CPP     = g++
AR = ar
RM      = rm -f

#Define the resource compiler.
RC = windres

## debug flag  
DBG_ENABLE := 0

OS = $(shell uname)

## source file path  
SRC_PATH  := ./src/
SRC_PATH_EXT := 

## target file name  
TARGET     := vis_demo

## get all source files  
SRCS := $(foreach spath, $(SRC_PATH), $(wildcard $(spath)*.c) $(wildcard $(spath)*.cpp))

## all .o based on all .c/.cpp
OBJS = $(SRCS:.c=.o)
OBJS := $(OBJS:.cpp=.o) 
OBJS := $(OBJS:.cc=.o) 

## macro define
DEFS := __LINUX__ OS_LINUX _FILE_OFFSET_BITS=64

#if freeimage is static-linked use this !
#DEFS += FREEIMAGE_LIB

## need libs, add at here  
LIBS := mklml_intel iomp5 mkldnn paddle_fluid glog gflags protobuf snappystream snappy z xxhash cudart cublas cudnn

## used headers  file path  
INCLUDE_PATH := /usr/local/cuda/include \
./libs/third_party/install/protobuf/include \
./libs/paddle/include \
./libs/paddle/ \
./include \
./libs/third_party/install/glog/include \
./libs/third_party/install/gflags/include \
./libs/third_party/install/xxhash/include \
./libs/third_party/install/snappy/include \
./libs/third_party/install/snappystream/include \
./libs/third_party/install/zlib/include \
./libs/third_party/boost \
./libs/third_party/eigen3 \
./libs/third_party/install/mklml/include \
./libs/third_party/install/mkldnn/include

#$(warning $(INCLUDE_PATH))

## used include librarys file path  
LIBRARY_PATH := /usr/local/cuda/lib64 \
./libs/third_party/install/protobuf/lib \
./libs/third_party/install/snappy/lib \
./libs/third_party/install/snappystream/lib \
./libs/third_party/install/zlib/lib \
./libs/third_party/install/glog/lib \
./libs/third_party/install/gflags/lib \
./libs/third_party/install/xxhash/lib \
./libs/third_party/install/mklml/lib \
./libs/third_party/install/mkldnn/lib \
/usr/lib/x86_64-linux-gnu \
./libs



## debug for debug info, when use gdb to debug  
ifeq (1, ${DBG_ENABLE})   
CFLAGS += -D_DEBUG -g -DDEBUG=1 
else
CFLAGS += -O3 -DNDEBUG
endif

#for ENCYPT flags

# rpath https://blog.csdn.net/kevin_darkelf/article/details/40891593
# https://blog.csdn.net/lusic01/article/details/89214976
ifeq ($(OS), Linux)
LIBS += dl rt pthread
CFLAGS += -fPIC
TARGET_EXT := 
LIBRARY_PATH += 
LDFLAGS += -Wl,--rpath=./libs
endif

CFLAGS += -msse4.2 -march=core2 -pipe $(foreach m, $(DEFS), -D$(m)) 
  
## get all include path  
CFLAGS  += $(foreach dir, $(INCLUDE_PATH), -I$(dir))  

CXXFLAGS += $(CFLAGS) -std=c++11

## get all library path  
LDFLAGS += -lpthread $(foreach lib, $(LIBRARY_PATH), -L$(lib))
  
## get all librarys  
LDFLAGS += $(foreach lib, $(LIBS), -l$(lib))

RCFLAGS ?= -DNDEBUG

default: all

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

%.o: %.cpp
	$(CPP) $(CXXFLAGS) -c $< -o $@
	
all: $(OBJS) $(RESOURCE)
	$(CPP) $(CXXFLAGS) -shared -o $(TARGET)$(TARGET_EXT) $(OBJS) $(RESOURCE) $(LDFLAGS)

clean:  
	$(RM) $(OBJS) $(TARGET).* $(RESOURCE)

命令:

./vis_demo \
--modeldir=./dataset/se_resnext50/model \
--data=./dataset/se_resnext50/data.txt \
--refer=./dataset/se_resnext50/result.txt \
--use_gpu=1

 

你可能感兴趣的:(深度学习,paddlepaddle)