Coder Social home page Coder Social logo

natanielruiz / android-yolo Goto Github PK

View Code? Open in Web Editor NEW
663.0 45.0 213.0 53.92 MB

Real-time object detection on Android using the YOLO network with TensorFlow

License: Apache License 2.0

Java 0.39% Makefile 0.10% C++ 46.61% Python 37.19% C 0.76% CMake 0.15% Objective-C 0.02% Objective-C++ 0.19% Shell 0.97% Jupyter Notebook 7.19% HTML 2.11% JavaScript 0.05% TypeScript 2.56% CSS 0.01% Starlark 1.48% Dockerfile 0.02% SWIG 0.21%
android-device yolo tensorflow android-studio tensorflow-yolo detection demo apk android object-detection

android-yolo's People

Contributors

counterfactualsimulation avatar hashimshafiq avatar natanielruiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-yolo's Issues

Fatal signal 6 (SIGABRT)

I am getting: "Android YOLO keeps stopping"

jni_utils.cc:92 'asset' Must be non NULL

Fatal signal 6 (SIGABRT), code -6 in tid 9860 (ImageListener)
[ 05-03 22:49:05.003 604: 604 W/ ]
debuggerd: handling request: pid=9839 uid=10357 gid=10357 tid=9860

Training new model

Very usefully app, I want to include my own training model to the app to be able to detect different objects or features. Any suggestion where to start?, thank you!

running time

Could you please provide the fps of you android app and the info of your device?

YOLO Model

How did you create this Model which you have added in assets part.

detect multiple objects

Thank you for your nice implementation.
I would like to know whether the APP can detect multiple objects at the same time,just like YOLO's demo picture dog.jpg?
Thanks~

Change count of classes

Hello! The app is hardcoded for 20 classes, i'm wanna change this. How i can leave only 15 classes? Thanks!

android apk problem

I downloaded "android-yolo.apk" but for installing I get "there is a problem parsing the package" error.
is need any specific Android version?
I'm using android 4.4.4

Darkness

Everything becomes much darker. When I open the app I can barely see anything even when pointing the camera towards the sun. When using my camera app everything looks alright

showing the error unsatisfied link error

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/org.tensorflow.tensorflowdemo-FebBpWvV3iIxT9KrXSaTRw==/base.apk"],nativeLibraryDirectories=[/data/app/org.tensorflow.tensorflowdemo-FebBpWvV3iIxT9KrXSaTRw==/lib/arm64, /system/lib64]]] couldn't find "libtensorflow_demo.so"

JNI Function

Cannot resolve corresponding JNI function Java_org_tensorflow_demo_TensorFlowClassifier_initializeTensorFlow Reports native method declarations in Java where no corresponding JNI function is found in the project.

How to resolve this in TensorFlowClassifier.java and ImageUtils.java?

Can I adapt this project to yolo v3?

Since I noticed that your project used .pb file for graph, how you get that? We tried several projects, and got errors like
Op type not registered 'LeakyRelu' in binary running on xxx. Make sure the Op and Kernel are registered in the binary running in this process.
How you get a proper .pb file?

detect custom object and notify

What is the output of the model? How can I capture the output for further processing?
Can it be made to detect custom objects and send notification emails?

crash when change android_graph.pb

Hello, this project is very good when i test, but when I use darkflow tool to convert my weight and cfg file to new android_graph.pb, then replace old one, and change the class_labels[] in java file, then got new apk, but test got crash message as below, Is it anything wrong in my step? anybody can helo me?

...
I/native: stat_summarizer.cc:33 StatSummarizer found 349 nodes
tensorflow_jni.cc:137 Creating session.
A/native: tensorflow_jni.cc:140 Could not create TensorFlow Graph: Not found: Op type not registered 'RealDiv'
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 3109 (ImageListener)
Application terminated.

jni error


Build fingerprint: 'Xiaomi/libra/libra:5.1.1/LMY47V/5.11.1:user/release-keys'
Revision: '0'
ABI: 'arm'
pid: 10250, tid: 10273, name: ImageListener >>> org.tensorflow.tensorflowdemo <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'jni_utils.cc:92 'asset' Must be non NULL'
r0 00000000 r1 00002821 r2 00000006 r3 00000000
r4 e29c4dd8 r5 00000006 r6 00000000 r7 0000010c
r8 e29c3ad4 r9 e29c39d8 sl 00000000 fp 00000000
ip 00002821 sp e29c3980 lr f7072e89 pc f709972c cpsr 600f0010

backtrace:
#00 pc 0003a72c /system/lib/libc.so (tgkill+12)
#1 pc 00013e85 /system/lib/libc.so (pthread_kill+52)
#2 pc 00014aa3 /system/lib/libc.so (raise+10)
#3 pc 0001131d /system/lib/libc.so (__libc_android_abort+36)
#4 pc 0000f54c /system/lib/libc.so (abort+4)
#5 pc 0053d03c /data/app/org.tensorflow.tensorflowdemo-1/lib/arm/libtensorflow_demo.so
#6 pc 0053d1bc /data/app/org.tensorflow.tensorflowdemo-1/lib/arm/libtensorflow_demo.so
#7 pc 0053d1d8 /data/app/org.tensorflow.tensorflowdemo-1/lib/arm/libtensorflow_demo.so
#8 pc 000746b4 /data/app/org.tensorflow.tensorflowdemo-1/lib/arm/libtensorflow_demo.so
#9 pc 00075594 /data/app/org.tensorflow.tensorflowdemo-1/lib/arm/libtensorflow_demo.so (ReadFileToProto(AAssetManager*, char const*, google::protobuf::MessageLite*)+1144)
#10 pc 00077bdc /data/app/org.tensorflow.tensorflowdemo-1/lib/arm/libtensorflow_demo.so (Java_org_tensorflow_demo_TensorFlowClassifier_initializeTensorFlow+1084)
#11 pc 000a2511 /system/lib/libart.so (art_quick_generic_jni_trampoline+32)
#12 pc 00136c1c /dev/ashmem/dalvik-main space (deleted)

code for yolo

I just want to Pass an Image and Get the Inference ...How Should I Do so...

How to use own data training model?

Hi, natanielruiz.
I am using darknet to traing my own data. I only detect one class. Could guide me how to modify your code to detect only one class? Do I need to modify the parameters in android-yolo/app/src/main/java/org/tensorflow/demo/TensorflowClassifier.java? or anything else?
Thank you.

Adding more labels?

Hello,

While looking through your code I noticed that you had defined the class labels as the YOLO v1 was trained on it. Are these all the available labels?

Looking at the source project, the same file didn't specify any labels, which made me confused as how accessing more labels would work (as in has it already been trained on more, and you're simply selectively choosing which labels to recognize)?

Thank you

using a different pb file

Hi,

I believe the pb file you derived is for yolo-voc, however, I would like to have a pb file for YOLOv2 608x608 ( https://pjreddie.com/darknet/yolo/).

Use darkflow (https://github.com/thtrieu/darkflow) I was able to create a pb file using yolo.cfg and yolo.weights.

I copied the yolo.pb file into the assets folder and when I try to install the apk, I get the following error:

03-31 16:08:26.398 19432-19652/org.tensorflow.tensorflowdemo I/tensorflow: CameraConnectionFragment: Opening camera preview: 480x640
03-31 16:08:26.402 19432-19432/org.tensorflow.tensorflowdemo V/BoundingBox: width: 1080.0 height: 1794.0
03-31 16:08:26.415 19432-19652/org.tensorflow.tensorflowdemo I/tensorflow: CameraConnectionFragment: Getting assets.
03-31 16:08:26.415 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:115 Loading TensorFlow.
03-31 16:08:26.415 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:117 Making new SessionOptions.
03-31 16:08:26.415 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:120 Got config, 0 devices
03-31 16:08:26.417 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:123 Session created.
03-31 16:08:26.417 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:126 Graph created.
03-31 16:08:26.417 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:130 Acquired AssetManager.
03-31 16:08:26.417 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:132 Reading file to proto: file:///android_asset/yolo.pb
03-31 16:08:26.797 19432-19652/org.tensorflow.tensorflowdemo I/native: stat_summarizer.cc:33 StatSummarizer found 349 nodes
03-31 16:08:26.798 19432-19652/org.tensorflow.tensorflowdemo I/native: tensorflow_jni.cc:137 Creating session.
03-31 16:08:26.827 19432-19652/org.tensorflow.tensorflowdemo A/native: tensorflow_jni.cc:140 Could not create TensorFlow Graph: Not found: Op type not registered 'RealDiv'
03-31 16:08:26.834 19432-19652/org.tensorflow.tensorflowdemo A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 19652 (ImageListener)
03-31 16:08:26.834 368: 368 W/ ]
debuggerd: handling request: pid=19432 uid=10094 gid=10094 tid=19652

ndk-build on OS X

Hi @natanielruiz - thanks for the library. Building on OS X 10.11.6 (El Capitan) using latest NDK (14.0.3770861) gives the following during ndk-build -

[armeabi-v7a] Compile++ arm : tensorflow_demo <= tensorflow_jni.cc
jni/./tensorflow_jni.cc: In function 'std::string ClassifyImage(const {anonymous}::RGBA*)':
jni/./tensorflow_jni.cc:318:33: error: 'output' cannot be used as a function
const float value = output(i);
^
jni/./tensorflow_jni.cc:319:16: error: base operand of '->' has non-pointer type 'std::vector'
top_results->push_back(value);
^
jni/./tensorflow_jni.cc:321:27: error: base operand of '->' has non-pointer type 'std::vector'
std::reverse(top_results->begin(), top_results->end());
^
jni/./tensorflow_jni.cc:321:49: error: base operand of '->' has non-pointer type 'std::vector'
std::reverse(top_results->begin(), top_results->end());
^
jni/./tensorflow_jni.cc: At global scope:
jni/./tensorflow_jni.cc:171:13: warning: 'void GetTopN(const Eigen::TensorMap<Eigen::Tensor<float, 1, 1, int>, 16>&, int, float, std::vector<std::pair<float, int> >*)' defined but not used [-Wunused-function]
static void GetTopN(
^
make[1]: *** [obj/local/armeabi-v7a/objs/tensorflow_demo/./tensorflow_jni.o] Error 1

output is a pointer to a tensor not a function - not sure how this compiles?

Object detection with custom pb file

Hello sir, I had custom pb file which I trained using tiny-yolo-voc with Darknet and then convert it using darkflow command
./flow --model cfg/tiny-yolo-voc.cfg --load bin/tiny-yolo-voc.weights --savepb --verbalise
My dataset is very simple which has only 1 class (cat) so the cfg I am using is changed at the final numer of filter
`[convolutional]
size=1
stride=1
pad=1
filters=30
activation=linear

[region]
anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52
bias_match=1
classes=1
coords=4
num=5
softmax=1
jitter=.2
rescore=1`
As you said from the readme file, you hardcoded your code with voc dataset with 20 classes. So i would like to ask just in my case when I only have 1 class then what changes should I made or would you give brief explanation to help me ?
Thank you so much !

New classess and new model with Yolo

Hi~ @natanielruiz Your project is very very helpful to me. I want to detect Food but I don't know how to train fooddata with yolo code. Could you share your Yolo code ? and can produce .pb file.

Thank you very very much!

TransactionTooLargeException

Application crash when open.

Exception thrown during pause
android.os.TransactionTooLargeException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:496)
at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:749)
at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:975)
at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3281)
at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3100)
at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:3467)
at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:13031)
at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:12914)
at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:13621)
at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13123)
at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)

Can't rebuild NDK because of errors in tensorflow_jni.cc

[armeabi-v7a] Compile++ arm : tensorflow_demo <= tensorflow_jni.cc
jni/./tensorflow_jni.cc: In function 'std::string ClassifyImage(const {anonymous}::RGBA*)':
jni/./tensorflow_jni.cc:319:33: error: 'output' cannot be used as a function
const float value = output(i);
^
jni/./tensorflow_jni.cc:320:16: error: base operand of '->' has non-pointer type 'std::vector'
top_results->push_back(value);
^
jni/./tensorflow_jni.cc:322:27: error: base operand of '->' has non-pointer type 'std::vector'
std::reverse(top_results->begin(), top_results->end());
^
jni/./tensorflow_jni.cc:322:49: error: base operand of '->' has non-pointer type 'std::vector'
std::reverse(top_results->begin(), top_results->end());
^
jni/./tensorflow_jni.cc: At global scope:
jni/./tensorflow_jni.cc:172:13: warning: 'void GetTopN(const Eigen::TensorMap<Eigen::Tensor<float, 1, 1, int>, 16>&, int, float, std::vector<std::pair<float, int>

*)' defined but not used [-Wunused-function]
static void GetTopN(
^
make: *** [obj/local/armeabi-v7a/objs/tensorflow_demo/./tensorflow_jni.o] Error 1

to add additional labels

@natanielruiz i thanks for sharing the implementation ,wonderful work . I have couple of questions

  1. Where can add/delete the labels
  2. Can i use weights trained on darknet having .weight file format

ndk-build error

Hi @natanielruiz ,I try to use ndk-build ,but there are some errors,could you please tell me how to fix it ?

E:\Xbot_material\AI-Camera-YOLO\jni-build>ndk-build
Android NDK: WARNING:jni/Android.mk:tensorflow_demo: non-system libraries in linker flags: jni/libs/armeabi-v7a/libprotos_all_cc.a jni/libs/armeabi-v7a/libprotobuf.a jni/libs/armeabi-v7a/libprotobuf_lite.a C:/Users/lisongting/AppData/Local/Android/Sdk/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a C:/Users/lisongting/AppData/Local/Android/Sdk/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK:     current module
[armeabi-v7a] Compile++ arm  : tensorflow_demo <= tensorflow_jni.cc
jni/./tensorflow_jni.cc: In function 'std::string ClassifyImage(const {anonymous}::RGBA*)':
jni/./tensorflow_jni.cc:318:33: error: 'output' cannot be used as a function
     const float value = output(i);
                                 ^
jni/./tensorflow_jni.cc:319:16: error: base operand of '->' has non-pointer type 'std::vector<float>'
     top_results->push_back(value);
                ^
jni/./tensorflow_jni.cc:321:27: error: base operand of '->' has non-pointer type 'std::vector<float>'
   std::reverse(top_results->begin(), top_results->end());
                           ^
jni/./tensorflow_jni.cc:321:49: error: base operand of '->' has non-pointer type 'std::vector<float>'
   std::reverse(top_results->begin(), top_results->end());
                                                 ^
jni/./tensorflow_jni.cc: At global scope:
jni/./tensorflow_jni.cc:171:13: warning: 'void GetTopN(const Eigen::TensorMap<Eigen::Tensor<float, 1, 1, int>, 16>&, int, float, std::vector<std::pair<float, int> >*)' defined but not used [-Wunused-function]
 static void GetTopN(
             ^
make: *** [obj/local/armeabi-v7a/objs/tensorflow_demo/./tensorflow_jni.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.