222x Filetype PPTX File size 2.20 MB Source: eisys.web.unc.edu
Remember Intent/Camera? • We used implicit intent to take pictures and get the image back. We want to use AI to detect what’s in it! TensorFlow Lite TensorFlow Lite • Use a pre-trained model or train one. Using TF Lite in Android • Get a pre-trained model – Download and copy (model and labels files) into the “app/assets” folder. https://www.tensorflow.org/lite/models • Gradle – edit build.gradle (module:app) dependencies { implementation('org.tensorflow:tensorflow-lite:0.0.0-nightly') { changing = true } implementation('org.tensorflow:tensorflow-lite-gpu:0.0.0-nightly') { changing = true } implementation('org.tensorflow:tensorflow-lite-support:0.0.0-nightly') { changing = true } } android { aaptOptions { noCompress "tflite" noCompress "lite" } } Android Code • Step 1 – Prepare the model “Interpreter” AssetFileDescriptor afd = getAssets().openFd("mobilenet_v1_1.0_224_quant.tflite"); FileInputStream fis = new FileInputStream(afd.getFileDescriptor()); FileChannel fc = fis.getChannel(); MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, afd.getStartOffset(), afd.getLength()); Interpreter interpreter = new Interpreter(mbb);
no reviews yet
Please Login to review.