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

Is there anyway to compile codes in caffe tools folder so i can do training? #14

Closed
ZhengRui opened this issue Jul 2, 2015 · 6 comments

Comments

@ZhengRui
Copy link

ZhengRui commented Jul 2, 2015

hello today i tried to add this into my Android.mk file so that i can compile caffe.cpp file, because i want to be able to train a network

$(CLEAR_VARS)

OpenCV_INSTALL_MODULES := on
OPENCV_CAMERA_MODULES := off
OPENCV_LIB_TYPE := STATIC
include $(REMOTE_PATH)/../../opencv/jni/OpenCV.mk

LOCAL_MODULE := caffe_tools

PRORO_CC := caffe/src/caffe/proto/caffe.pb.cc

LOCAL_SRC_FILES := $(PRORO_CC) caffe/tools/caffe.cpp

LOCAL_C_INCLUDES := $(REMOTE_PATH)/../../eigen3 \
    $(LOCAL_PATH)/caffe/include $(LOCAL_PATH)/caffe/include/caffe/proto \
    $(REMOTE_PATH)/../../Boost-for-Android/build/include/boost-1_55 \
    $(REMOTE_PATH)/../../opencv/jni/include \
    $(REMOTE_PATH)/../../../gflags/build/include

LOCAL_STATIC_LIBRARIES += gflags
LOCAL_SHARED_LIBRARIES := caffe
LOCAL_CPPFLAGS += -pthread -fPIC -fexceptions -frtti -std=c++11 -DUSE_EIGEN -DCPU_ONLY
LOCAL_LDLIBS += -lm -llog -L$(REMOTE_PATH)/../../../gflags/build/lib/
LOCAL_ARM_MODE := arm
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
LOCAL_ARM_NEON := true
endif

include $(BUILD_SHARED_LIBRARY)

i don't know if this is the right direction to make it able to train a network, i compiled gflags by myself and tried to link to it, but i got this error:

Error:error: undefined reference to 'google::FlagRegisterer::FlagRegisterer(char const*, char const*, char const*, char const*, void*, void*)'

for the 4 functions in caffe.cpp file, i think it's because the gflags is not build with Android platform, but i don't know what should i do now, any guide towards making it able to train a network?

@ZhengRui ZhengRui changed the title Is there anyway to compile codes in caffe tools folder? Is there anyway to compile codes in caffe tools folder so i can do training? Jul 2, 2015
@sh1r0
Copy link
Owner

sh1r0 commented Sep 11, 2015

Sorry for my late response. Did you try to build glags for Android? But actually, it's not required to make it. You can simply copy and modify train() in caffe/tools/caffe.cpp and put it somewhere (e.g., caffe_mobile.cpp) and implement a corresponding jni call for the usage.

@ZhengRui
Copy link
Author

I just include the header files of gflag but i didn't use its compiled library, i noticed that it's not required. After compiling most dependencies for arm platform including leveldb, lmdb, snappy, and changing the caffe code a bit, now i can train mnist dataset and the trained model did get 98% accuracy after i loaded and tested it on my laptop. But only leveldb worked well, lmdb got some problems. Also i think start_logger() function may need to be changed a bit to print the training output from caffe correctly. I have putted it down for many days, hope could make it work more smoothly when i got time.

@sh1r0
Copy link
Owner

sh1r0 commented Sep 11, 2015

Sorry for my possible misunderstanding. Your laptop? (ARM-based?)

@ZhengRui
Copy link
Author

i mean i trained it on the phone, but during training from the output of my android studio it's quite messy, i am not sure how good the model trained, so i loaded to my laptop and test it, accuracy is fine.

@sh1r0
Copy link
Owner

sh1r0 commented Sep 11, 2015

Wow, that's great!!

@sh1r0
Copy link
Owner

sh1r0 commented Dec 29, 2015

Cmake is used to build the caffe lib now (except some modules. e.g. python, matlab, etc.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants