Skip to content

Instantly share code, notes, and snippets.

@makorowy
Created February 25, 2018 19:04
Show Gist options
  • Save makorowy/cf1aac8c65279f66427d6ed0b60394e4 to your computer and use it in GitHub Desktop.
Save makorowy/cf1aac8c65279f66427d6ed0b60394e4 to your computer and use it in GitHub Desktop.
TensorFlow - Hot or Not example. Creating a classifier.
class MainActivity : AppCompatActivity() {
private lateinit var classifier: Classifier
//other properties
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
checkPermissions()
}
private fun checkPermissions() {
if (arePermissionAlreadyGranted()) {
init()
} else {
requestPermissions()
}
}
private fun init() {
createClassifier()
takePhoto()
}
private fun createClassifier() {
classifier = ImageClassifierFactory.create(
assets,
GRAPH_FILE_PATH,
LABELS_FILE_PATH,
IMAGE_SIZE,
GRAPH_INPUT_NAME,
GRAPH_OUTPUT_NAME
)
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment