{"id":13419041,"url":"https://github.com/solrex/caffe-mobile","last_synced_at":"2025-03-15T04:31:44.677Z","repository":{"id":145916420,"uuid":"80809550","full_name":"solrex/caffe-mobile","owner":"solrex","description":"Optimized (for size and speed) Caffe lib for iOS and Android with out-of-the-box demo APP.","archived":false,"fork":false,"pushed_at":"2018-08-07T07:01:16.000Z","size":701,"stargazers_count":317,"open_issues_count":11,"forks_count":122,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-07-31T22:45:22.747Z","etag":null,"topics":["android","app","caffe","cnn","deep-learning","dnn","ios","mobile-app"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solrex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-03T08:07:33.000Z","updated_at":"2024-07-17T15:03:03.000Z","dependencies_parsed_at":"2023-04-09T19:01:54.161Z","dependency_job_id":null,"html_url":"https://github.com/solrex/caffe-mobile","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrex%2Fcaffe-mobile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrex%2Fcaffe-mobile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrex%2Fcaffe-mobile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solrex%2Fcaffe-mobile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solrex","download_url":"https://codeload.github.com/solrex/caffe-mobile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243685506,"owners_count":20330980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","app","caffe","cnn","deep-learning","dnn","ios","mobile-app"],"created_at":"2024-07-30T22:01:10.527Z","updated_at":"2025-03-15T04:31:44.671Z","avatar_url":"https://github.com/solrex.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings"],"sub_categories":[],"readme":"Caffe on Mobile Devices\n==================\n\nOptimized (for size and speed) Caffe lib for iOS and Android with demo APP. (CPU_ONLY, NO_BACKWARD, NO_BOOST, NO_HDF5, NO_LEVELDB)\n\n# Screenshots\n\niPhone5s | Meizu M3 note\n:---------:| :-------------:\n\u003cimg src=\"https://raw.githubusercontent.com/solrex/caffe-mobile/master/screenshot/CaffeSimpleiPhone5s.png\" width=\"70%\" /\u003e | \u003cimg src=\"https://raw.githubusercontent.com/solrex/caffe-mobile/master/screenshot/CaffeSimpleM3-Note.jpg\" width=\"40%\" /\u003e\n\n\u003e NOTE: Cmake version 3.7.2 builds faster lib than version 3.5.1 (verified on Ubuntu 16.10/Android NDK r14). Don't know why. So please use a newer cmake if you can.\n\n\u003e NOTE: NDK version r16+ is not supported. NDK r16 moves all standalone headers to [unified headers](https://android.googlesource.com/platform/ndk/+/ndk-release-r16/CHANGELOG.md). It causes a lot of cross compile problems which I cannot resolve. See issue [#52](https://github.com/solrex/caffe-mobile/issues/52).\n\n# For iPhone or iPhone Simulator\n\n## Step 1: Build Caffe-Mobile Lib with cmake\n\n```\n$ git clone --recursive https://github.com/solrex/caffe-mobile.git\n$ ./tools/build_ios.sh\n```\n\n## Step 2: Build iOS App: CaffeSimple with Xcode\n\n - For CaffeSimple to run, you need a pre-trained LeNet on MNIST caffe model and the weight file.\nFollow the instructions in [Training LeNet on MNIST with Caffe](http://caffe.berkeleyvision.org/gathered/examples/mnist.html) to train your LeNet Model on MNIST. Then copy the the trained weight file `caffe/examples/mnist/lenet_iter_10000.caffemodel` to CaffeSimple app directory. Note: Check the batch size setting in net.prototxt, set it to `1` if needed.\n\n```\n$ cp $CAFFE/examples/mnist/lenet_iter_10000.caffemodel \\\n     $CAFFE_MOBILE/examples/ios/simple/CaffeSimple/data/weight.caffemodel\n```\n\n - If you want to use your self-defined caffe network, use `tools/prototxt2bin.py net.prototxt` to convert your prototxt to protobin. Then place `net.protobin` in `$CAFFE_MOBILE/examples/ios/simple/CaffeSimple/data/`.\n\n - Load the Xcode project inside the `$CAFFE_MOBILE/examples/ios/simple/` folder, connect your iPhone to Mac, change target to \"Your Name's iPhone\", and press Command-R to build and run it on your connected device.\n\n# For Android\n\n## Step 1: Build Caffe-Mobile Lib with cmake\n\nTest passed ANDROID_ABI:\n\n - [x] arm64-v8a\n - [x] armeabi\n - [x] armeabi-v7a with NEON (not stable)\n\n```bash\n$ git clone --recursive https://github.com/solrex/caffe-mobile.git\n$ export NDK_HOME=/path/to/your/ndk  # C:/path/to/your/ndk on MinGW64 (/c/path/to/your/ndk not work for OpenBLAS)\n$ ./tools/build_android.sh\n```\n\n\u003e For Windows Users:\n\u003e\n\u003e Install the following softwares before you start:\n\u003e\n\u003e 1. [Git for Windows](https://github.com/git-for-windows/git/releases/download/v2.13.2.windows.1/Git-2.13.2-64-bit.exe): A shell environment(MinGW64) to run the build.\n\u003e 1. [tdm64-gcc-5.1.0-2.exe](http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-5.1.0-2.exe/download): The GNU toolchain, remember to copy `/path/to/TDM-GCC-64/bin/mingw32-make.exe` to `/path/to/TDM-GCC-64/bin/make.exe`.\n\u003e 1. [cmake-3.8.2-win64-x64.msi](https://cmake.org/files/v3.8/cmake-3.8.2-win64-x64.msi): Cmake\n\u003e\n\u003e Then start `Git Bash` application to run the build script.\n\n## Step 2: Build Android App: CaffeSimple with Android Studio\n\n - For CaffeSimple to run, you need a pre-trained LeNet on MNIST caffe model and the weight file.\nFollow the instructions in [Training LeNet on MNIST with Caffe](http://caffe.berkeleyvision.org/gathered/examples/mnist.html) to train your LeNet Model on MNIST. Then copy the model file `caffe/examples/mnist/lenet.prototxt` and the trained weight file `caffe/examples/mnist/lenet_iter_10000.caffemodel` to the SD card root of your Android mobile phone. Check the batch size setting in net.prototxt, set it to `1` if needed.\n\n```\n$ adb push $CAFFE/examples/mnist/lenet_iter_10000.caffemodel \\\n     /sdcard/weight.caffemodel\n$ adb push $CAFFE_MOBILE/examples/ios/simple/CaffeSimple/data/net.protobin \\\n     /sdcard/net.protobin\n$ adb push $CAFFE_MOBILE/examples/ios/simple/CaffeSimple/data/test_image.jpg \\\n     /sdcard/test_image.jpg\n```\n\n - If you want to use your self-defined caffe network, use `tools/prototxt2bin.py net.prototxt` to convert your prototxt to protobin. Then push `net.protobin` to your sdcard root directory.\n\n - Load the Android studio project inside the `$CAFFE_MOBILE/examples/android/CaffeSimple/` folder, and press Command-R to build and run it on your connected device.\n\n# For MacOSX \u0026 Ubuntu\n\n## Step 1: Install dependency\n\n```\n$ brew install protobuf # MacOSX\n$ sudo apt install libprotobuf-dev protobuf-compiler libatlas-dev # Ubuntu\n```\n\n## Step 2: Build Caffe-Mobile Lib with cmake\n\n```\n$ git clone --recursive https://github.com/solrex/caffe-mobile.git\n$ mkdir build\n$ cd ../build\n$ cmake ..\n$ make -j 4\n```\n\n## Step 3: Build Caffe-bin with cmake\n\n```\n$ brew install gflags\n$ cmake .. -DTOOLS\n$ make -j 4\n```\n\n# Thanks\n\n - Based on https://github.com/BVLC/caffe\n - Inspired by https://github.com/chyh1990/caffe-compact\n - Android JNI code based on https://github.com/sh1r0/caffe\n - Use https://github.com/Yangqing/ios-cmake\n - Use https://github.com/taka-no-me/android-cmake\n - Windows build script inspired by https://github.com/luoyetx/mini-caffe/tree/master/android\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolrex%2Fcaffe-mobile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolrex%2Fcaffe-mobile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolrex%2Fcaffe-mobile/lists"}