Last active
January 17, 2019 09:39
-
-
Save makorowy/208c463381a22bc21a151ce5cb8baa61 to your computer and use it in GitHub Desktop.
TensorFlow Hot or Not example. Classifier factory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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