A stand-alone Android app ported from Tensorflow TF detect
in 1.4.0
modified with Yolo V2 coco
.
- Install Android Studio
- Import the project on Android Studio
File->New->Project from Vision Control->GitHub
orgit clone
this repository and import this project to Android Studio. - Install missing dependencies in Android Studio, it's smart enough to walk you through the installation steps. e.g. you probablly need to install
CMake
, mark the checkboxCMake
underTools > Android > SDK Manager
. For more details, see Add C and C++ Code to Your Project. - DONE, just run the app on your smartphone!
Err, close enough Does that leopard look like a bird? :p Blame coco
for not having enough classes. (powered by my Google Pixel 2)
You can find the pb
model generated from cfg
and weights
under app/src/main/assets
or download the latest one from here:
However, if you're interested in other YOLO models, download more cfg
and weights from 💥 DARKNET.
Make sure always download the matching cfg
and weights
otherwise you won't be able to generate a .pb
model.
To start TF detect
in YOLO mode, you need to feed it with a YOLO model in .pb
. I forked the tool from Darkflow
and adapted it to the latest YOLO model, so basically, you just need to run
python3 flow --model cfg/tiny-yolo.cfg --load bin/tiny-yolo.weights --savepb --verbalise
If you're interested in details of the modification, see the troubleshooting
section of my forked Darkflow
I may write a python script to pull those updates when I have time 🙈
gradle/wrapper/*.jar
: latest librariesapp/src/main/cpp/
: latest libraries
You have to be careful, when you pull the native C libraries from tensorflow jni,
you need to change the paths of #include
header files in a programmatic way, because the relative path has changed in the android app structure.
For example:
#include "tensorflow/examples/android/jni/rgb2yuv.h" (in tensorflow repo)
#include "rgb2yuv.h" (stand-alone android app)
and build.gradle
will call CMakeList.txt
to compile all native libraries for you. There's nothing more you need to do. Awesome! 💪