Skip to content

Instantly share code, notes, and snippets.

@makorowy
Last active January 17, 2019 09:39
Show Gist options
  • Save makorowy/208c463381a22bc21a151ce5cb8baa61 to your computer and use it in GitHub Desktop.
Save makorowy/208c463381a22bc21a151ce5cb8baa61 to your computer and use it in GitHub Desktop.
TensorFlow Hot or Not example. Classifier factory.
object ImageClassifierFactory {
fun create(
assetManager: AssetManager,
graphFilePath: String,
labelsFilePath: String,
imageSize: Int,
inputName: String,
outputName: String
): Classifier {
val labels = FileUtils.getLabels(assetManager, labelsFilePath)
return ImageClassifier(
inputName = inputName,
outputName = outputName,
imageSize = imageSize.toLong(),
labels = labels,
imageBitmapPixels = IntArray(imageSize * imageSize),
imageNormalizedPixels = FloatArray(imageSize * imageSize * COLOR_CHANNELS),
results = FloatArray(labels.size),
tensorFlowInference = TensorFlowInferenceInterface(assetManager, graphFilePath)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment