Last active
December 15, 2018 07:28
-
-
Save pjwelcome/47f16f80d29d9aefbc7c9c4725e59a76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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