Skip to content

Instantly share code, notes, and snippets.

🚀
To Boldly Go Where No Man Has Gone Before

Harshit Dwivedi the-dagger

🚀
To Boldly Go Where No Man Has Gone Before
Block or report user

Report or block the-dagger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View builtin_ops_jni.cc
...
#include "tensorflow/lite/java/src/main/native/normalize.h"
#include "tensorflow/lite/java/src/main/native/predict.h"
#include "tensorflow/lite/java/src/main/native/extract_feature.h"
namespace tflite {
...
View BUILD
...
hdrs = [
"exception_jni.h",
"nativeinterpreterwrapper_jni.h",
"tensor_jni.h",
"tensorflow_lite_jni.h",
"normalize.h",
"predict.h",
"extract_feature.h",
],
View bazel.build
bazel build --cxxopt='--std=c++11' -c opt \
--fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a \
//tensorflow/lite/java:tensorflow-lite
View gist:aac1f3aee91f89b832170dde73e9e6b5
> Task :crash:app:preDebugBuild FAILED
Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.
Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.
> Task :admob:app:preDebugBuild FAILED
Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.
> Task :appindexing:app:preDebugBuild FAILED
Warning: The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended.
View build.gradle
dependencies {
// ...
// Add the In-App Messaging depencency:
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.0'
}
View MainActivity.kt
private fun getPokemonFromBitmap(bitmap: Bitmap?) {
val inputs = FirebaseModelInputs.Builder()
.add(convertBitmapToByteBuffer(bitmap)) // add() as many input arrays as your model requires
.build()
fireBaseInterpreter.run(inputs, inputOutputOptions)
?.addOnSuccessListener {
val pokeList = mutableListOf<Pokemon>()
/**
* Run a foreach loop through the output float array containing the probabilities
View MainActivity.kt
val pokeArray: Array<String> = arrayOf("abra", "aerodactyl", "alakazam", "arbok", "arcanine", "articuno", "beedrill", "bellsprout",
"blastoise", "bulbasaur", "butterfree", "caterpie", "chansey", "charizard", "charmander", "charmeleon", "clefable", "clefairy", "cloyster", "cubone", "dewgong",
"diglett", "ditto", "dodrio", "doduo", "dragonair", "dragonite", "dratini", "drowzee", "dugtrio", "eevee", "ekans", "electabuzz",
"electrode", "exeggcute", "exeggutor", "farfetchd", "fearow", "flareon", "gastly", "gengar", "geodude", "gloom",
"golbat", "goldeen", "golduck", "golem", "graveler", "grimer", "growlithe", "gyarados", "haunter", "hitmonchan",
"hitmonlee", "horsea", "hypno", "ivysaur", "jigglypuff", "jolteon", "jynx", "kabuto",
"kabutops", "kadabra", "kakuna", "kangaskhan", "kingler", "koffing", "krabby", "lapras", "lickitung", "machamp",
"machoke", "machop", "magikarp", "magmar", "magnemite", "magneton", "mankey", "marowak", "meowth", "metapod",
"m
View MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
//...
private fun getPokemonFromBitmap(bitmap: Bitmap?) {
val inputs = FirebaseModelInputs.Builder()
.add(convertBitmapToByteBuffer(bitmap)) // add() as many input arrays as your model requires
.build()
fireBaseInterpreter.run(inputs, inputOutputOptions)
?.addOnSuccessListener {
View MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
//...
val firebaseModelOptions = FirebaseModelOptions.Builder()
.setLocalModelName("pokedex")
.setCloudModelName("pokedex")
.build()
fireBaseInterpreter = FirebaseModelInterpreter.getInstance(firebaseModelOptions)!!
//...
}
View MainActivity.kt
class PokemonDetectorActivity : BaseCameraActivity() {
companion object {
/** Dimensions of inputs. */
const val DIM_IMG_SIZE_X = 224
const val DIM_IMG_SIZE_Y = 224
const val DIM_BATCH_SIZE = 1
const val DIM_PIXEL_SIZE = 3
const val IMAGE_MEAN = 128
private const val IMAGE_STD = 128.0f
You can’t perform that action at this time.