Skip to content

Instantly share code, notes, and snippets.

@pjwelcome
Last active December 15, 2018 07:28
Show Gist options
  • Save pjwelcome/47f16f80d29d9aefbc7c9c4725e59a76 to your computer and use it in GitHub Desktop.
Save pjwelcome/47f16f80d29d9aefbc7c9c4725e59a76 to your computer and use it in GitHub Desktop.
val requestBody = ModelRequestBody(PayloadRequest(ModelImage(imgString)))
Network("https://automl.googleapis.com/v1beta1/",true).getRetrofitClient().create(Endpoint::class.java).classifyImage(requestBody).enqueue(object : Callback<PayloadResult> {
override fun onResponse(call: Call<PayloadResult>?, response: Response<PayloadResult>?) {
if (response!!.isSuccessful) {
result_textview.text = "${response?.body()?.items?.first()?.displayName} Score: ${(response?.body()?.items?.first()?.classification?.let { it.score * 100 })}"
}
}
override fun onFailure(call: Call<PayloadResult>, t: Throwable) {
print(t!!.message)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment