{"id":46748,"date":"2020-03-27T10:36:01","date_gmt":"2020-03-27T17:36:01","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/xamarin\/?p=46748"},"modified":"2020-09-15T11:13:55","modified_gmt":"2020-09-15T18:13:55","slug":"image-classification-xamarin-android","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/image-classification-xamarin-android\/","title":{"rendered":"Android Image Classification with TensorFlow Lite &#038; Azure Custom Vision Service"},"content":{"rendered":"<p style=\"text-align: center;\"><em>This is a guest blog by <a href=\"https:\/\/twitter.com\/hindrikes\">Daniel Hindrikes<\/a>. Daniel is a Microsoft MVP, Speaker, and Xamarin + Cloud Solution Architect<span class=\"css-901oao css-16my406 r-1qd0xha r-ad9z0x r-bcqeeo r-qvutc0\">\u00a0at\u00a0<a href=\"https:\/\/tretton37.com\">tretton37<\/a>.<\/span><\/em><\/p>\n<p>Image Classification allows our Xamarin apps to recognize objects in a photo.<\/p>\n<p>Being able to take a photo and recognize its contents is becoming more and more common. We experience it in our banking apps when making a mobile deposit, in our photo apps when adding filters, and in our HotDog apps to determine whether or not our meal is a hotdog.<\/p>\n<p>Thanks to Azure Custom Vision Service, we don&#8217;t have to learn\u00a0complex machine learning algorithms to implement image classification.<\/p>\n<p>This article will walkthrough how to implement it using Azure&#8217;s <a href=\"https:\/\/customvision.ai\/?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service<\/a>, <a href=\"https:\/\/www.tensorflow.org\/lite\">TensorFlow Lite<\/a>\u00a0(an open source machine learning platform) and <a href=\"https:\/\/docs.microsoft.com\/xamarin\/android?WT.mc_id=aiapril-xamblog-bramin\">Xamarin.Android<\/a>.<\/p>\n<p><strong>Note:<\/strong> For <a href=\"https:\/\/docs.microsoft.com\/xamarin\/ios?WT.mc_id=aiapril-xamblog-bramin\">Xamarin.iOS<\/a>, we can also use Azure&#8217;s <a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service<\/a> with <a href=\"https:\/\/docs.microsoft.com\/xamarin\/ios\/platform\/introduction-to-ios11\/coreml?WT.mc_id=aiapril-xamblog-bramin\">CoreML<\/a>, but we&#8217;ll save that for another blog post.<\/p>\n<p><center><img decoding=\"async\" class=\"wp-image-46792 alignnone\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/mushrooms.gif\" alt=\"Image Classification Mushrooms\" width=\"245\" height=\"499\" \/><\/center><\/p>\n<h2><\/h2>\n<h2>Image Classification Libraries<\/h2>\n<p>We&#8217;ll be leveraging Azure Custom Vision Service and TensorFlow Lite to implement our image classification.<\/p>\n<h3>1. Azure Custom Vision Service<\/h3>\n<p>Azure&#8217;s <a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service<\/a> makes it easy to create and train machine learning models &#8211; no previous Artificial Intelligence (AI) or Machine Learning (ML) experience is necessary.<\/p>\n<p>Using the <a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service Web Portal<\/a>, we can do the following without writing any AI\/ML code:<\/p>\n<ol>\n<li>Upload a training image<\/li>\n<li>Tag \/ Label the object(s) in the image<\/li>\n<li>Repeat (the model gets better with more training data)<\/li>\n<li>That&#8217;s it &#8211; Custom Vision Service takes care of the rest!<\/li>\n<\/ol>\n<h3><\/h3>\n<h3>2. TensorFlow Lite<\/h3>\n<p><a href=\"https:\/\/www.tensorflow.org\/lite\">TensorFlow Lite<\/a> is an open source machine learning platform\u00a0that allows us to use <a href=\"https:\/\/www.tensorflow.org\">TensorFlow<\/a> on IoT and Mobile devices.<\/p>\n<p>Both TensoryFlow Lite and TensorFlow are completely <a href=\"https:\/\/github.com\/tensorflow\/tensorflow\">open-source on GitHub<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Implementing Image Classification with Azure + Xamarin.Android<\/h2>\n<p>&nbsp;<\/p>\n<p>The completed\u00a0Image Classification sample app is available here on GitHub: <a href=\"https:\/\/github.com\/dhindrik\/MushroomDetector\/\">https:\/\/github.com\/dhindrik\/MushroomDetector\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>1. Training the Model<\/h3>\n<p>Using the <a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service Web Portal<\/a>, we will first train models for image classification.<\/p>\n<ol>\n<li>In the <a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service Web Portal<\/a>, click <strong>New Project<\/strong><\/li>\n<\/ol>\n<p><center><img decoding=\"async\" class=\"alignnone size-medium wp-image-46795\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/New-Project-300x300.png\" alt=\"Image New Project\" width=\"300\" height=\"300\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/New-Project-300x300.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/New-Project-1024x1022.png 1024w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/New-Project-150x150.png 150w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/New-Project-768x767.png 768w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/New-Project.png 1127w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/center>2. In the\u00a0<strong>Create new project<\/strong> window, make the following selections:<\/p>\n<ul>\n<li><strong>Name:<\/strong>\u00a0XamarinImageClassification<\/li>\n<li><strong>Description:\u00a0<\/strong>Identify Objects in Images<\/li>\n<li><strong>Resource: <\/strong>[Create a new resource]<\/li>\n<li><strong>Project Type:\u00a0<\/strong>Classification<\/li>\n<li><strong>Classification Types:\u00a0<\/strong>Multilabel (Multiple tags per image)<\/li>\n<li><strong>Domains: <\/strong>General (compact)<\/li>\n<li><strong>Export Capabilities:\u00a0<\/strong>Basic platforms<\/li>\n<\/ul>\n<ol>\n<li>\n<p>In the <strong>Create new project<\/strong> window, click\u00a0<strong>Create project<\/strong><\/p>\n<\/li>\n<li>\n<p>In the\u00a0<strong>XamarinImageClassification<\/strong> window, click\u00a0<strong>Add images<\/strong><\/p>\n<\/li>\n<li>\n<p>Select images that contain the object to identify<\/p>\n<\/li>\n<li>\n<p>In the\u00a0<strong>Image Upload<\/strong> window, add a tag<\/p>\n<\/li>\n<\/ol>\n<p><span style=\"font-size: 10pt;\"><strong>Note:\u00a0<\/strong>In this example, we are tagging images of mushrooms<\/span><\/p>\n<ol>\n<li>In the\u00a0<strong>Image upload<\/strong> window, click\u00a0<strong>Upload<\/strong><\/li>\n<\/ol>\n<p><span style=\"font-size: 10pt;\"><strong>Note:<\/strong>\u00a0Continue uploading images until you have at least 5 images for each tag<\/span><\/p>\n<p><center><img decoding=\"async\" class=\"alignnone size-medium wp-image-46796\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Upload-Mushroom-Images-300x294.png\" alt=\"Image Upload Mushroom Images\" width=\"300\" height=\"294\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Upload-Mushroom-Images-300x294.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Upload-Mushroom-Images-1024x1004.png 1024w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Upload-Mushroom-Images-768x753.png 768w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Upload-Mushroom-Images.png 1147w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/center>8. In the <strong>XamarinImageClassification<\/strong> window, in the top-right of the window, click the\u00a0<strong>Train Model\u00a0<\/strong>button (the green image of gears)<\/p>\n<ol>\n<li>\n<p>In the\u00a0<strong>Choose Training Type<\/strong> window, select\u00a0<strong>Quick Training<\/strong><\/p>\n<\/li>\n<li>\n<p>In the\u00a0<strong>Choose Training Type<\/strong> window, select\u00a0<strong>Train<\/strong><\/p>\n<\/li>\n<\/ol>\n<p><center><img decoding=\"async\" class=\"alignnone size-medium wp-image-46797\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Train-300x207.png\" alt=\"Image Train\" width=\"300\" height=\"207\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Train-300x207.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Train-1024x708.png 1024w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Train-768x531.png 768w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Train-1536x1062.png 1536w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Train.png 1627w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/center>&nbsp;<\/p>\n<h3>2. Export Trained Models from Azure Custom Vision Service<\/h3>\n<p>Now that we&#8217;ve trained our model, let&#8217;s <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/cognitive-services\/custom-vision-service\/export-your-model?WT.mc_id=aiapril-xamblog-bramin\">export it for use in our mobile app<\/a>.<\/p>\n<p>This allows us to use the model without an internet connection which improves the user&#8217;s privacy because their photos will never leave their mobile device.<\/p>\n<p>To export our model, lets do the following:<\/p>\n<ol>\n<li>\n<p>On the <strong>XamarinImageClassifcation<\/strong> window, on the top of the page, select the <strong>Performance<\/strong>\u00a0tab<\/p>\n<\/li>\n<li>\n<p>On The <strong>Performance<\/strong> tab, tap the <strong>Export<\/strong>\u00a0button (the downward-pointing arrow)<\/p>\n<\/li>\n<\/ol>\n<p><span style=\"font-size: 1rem;\">3. On the <\/span><strong style=\"font-size: 1rem;\">Choose your platform<\/strong><span style=\"font-size: 1rem;\">\u00a0window, select\u00a0<strong>TensorFlow<\/strong><\/span><\/p>\n<p><center><img decoding=\"async\" class=\"alignnone size-medium wp-image-46798\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Export-to-TensorFlow-300x288.png\" alt=\"Image Export to TensorFlow\" width=\"300\" height=\"288\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Export-to-TensorFlow-300x288.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Export-to-TensorFlow-1024x983.png 1024w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Export-to-TensorFlow-768x737.png 768w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Export-to-TensorFlow.png 1172w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/center>4. In the <strong>Choose your platform<\/strong>\u00a0dropdown, select <strong>TensorFlow Lite<\/strong><\/p>\n<ol>\n<li>In the <strong>Choose your platform <\/strong>window,\u00a0select\u00a0<strong>Download<\/strong><\/li>\n<\/ol>\n<p><center><img decoding=\"async\" class=\"alignnone size-medium wp-image-46799\" src=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Choose-Your-Platform-300x149.png\" alt=\"Image Choose Your Platform\" width=\"300\" height=\"149\" srcset=\"https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Choose-Your-Platform-300x149.png 300w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Choose-Your-Platform-1024x508.png 1024w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Choose-Your-Platform-768x381.png 768w, https:\/\/devblogs.microsoft.com\/xamarin\/wp-content\/uploads\/sites\/44\/2020\/03\/Choose-Your-Platform.png 1297w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/center>&nbsp;<\/p>\n<h3>3. Import TensorFlowLite into our Xamarin.Android App<\/h3>\n<ol>\n<li>In our Xamarin.Android project, install the <a href=\"https:\/\/www.nuget.org\/packages\/Xamarin.TensorFlow.Lite\">TensorFlow Lite NuGet Package<\/a><\/li>\n<\/ol>\n<p><span style=\"font-size: 10pt;\"><strong>Note:<\/strong>\u00a0This NuGet Package is an <a href=\"https:\/\/github.com\/xamarin\/XamarinComponents\/tree\/master\/XPlat\/TensorFlow.Lite\">open-source project<\/a> created by the Xamarin team at Microsoft. It contains C# bindings for the <a href=\"https:\/\/github.com\/tensorflow\/tensorflow\">orginal TensorFlow Lite library<\/a> which makes it possible to use in our Xamarin.Android app<\/span><\/p>\n<p><center><img decoding=\"async\" class=\"alignnone\" src=\"https:\/\/user-images.githubusercontent.com\/13558917\/76364288-b24f5880-631c-11ea-9d0a-d817efab4233.png\" width=\"536\" height=\"89\" \/><\/center>2. Unzip the exported model that we downloaded from the <a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Custom Vision Service Web Portal<\/a><\/p>\n<p><span style=\"font-size: 10pt;\"><strong>Note:\u00a0<\/strong>Inside the zip-file, are <span class=\"lang:default decode:true crayon-inline \">labels.txt<\/span>\u00a0 and <span class=\"lang:default decode:true crayon-inline\">model.tflite<\/span>:<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 10pt;\"><span class=\"lang:default decode:true crayon-inline\">labels.txt<\/span>\u00a0 contains the image tags created during the training preparation at the Custom Vision website<\/span><\/li>\n<li><span style=\"font-size: 10pt;\"><span class=\"lang:default decode:true crayon-inline \">models.tflite<\/span>\u00a0 is the machine learning model that we use to make our predictions<\/span><\/li>\n<\/ul>\n<ol>\n<li>\n<p>In Visual Studio, in the Xamarin.Android project, right-click on the <strong>Assets<\/strong> folder<\/p>\n<\/li>\n<li>\n<p>On the right-click menu, select <strong>Add<\/strong>\u00a0&gt; <strong>Existing Item&#8230;<\/strong><\/p>\n<\/li>\n<li>\n<p>In the <strong>Add Existing Item<\/strong>\u00a0menu, select both of the recently unzipped files:<\/p>\n<\/li>\n<\/ol>\n<ul>\n<li><strong>models.tflite<\/strong><\/li>\n<li><strong>labels.txt<\/strong><\/li>\n<\/ul>\n<ol>\n<li>\n<p>In Visual Studio, in the <strong>Xamarin.Android<\/strong> &gt; <strong>Assets<\/strong>\u00a0folder, right-click on <strong>labels.txt<\/strong><\/p>\n<\/li>\n<li>\n<p>In the right-click menu, select <strong>Properties<\/strong><\/p>\n<\/li>\n<li>\n<p>In the <strong>Properties<\/strong>\u00a0window, select <strong>Build Action<\/strong>\u00a0&gt; <strong>Android Asset<\/strong><\/p>\n<\/li>\n<li>\n<p>In Visual Studio, in the <strong>Xamarin.Android<\/strong> &gt; <strong>Assets<\/strong>\u00a0folder, right-click on <strong>models.tflite<\/strong><\/p>\n<\/li>\n<li>\n<p>In the right-click menu, select <strong>Properties<\/strong><\/p>\n<\/li>\n<li>\n<p>In the <strong>Properties<\/strong>\u00a0window, select <strong>Build Action<\/strong>\u00a0&gt; <strong>Android Asset<\/strong><\/p>\n<\/li>\n<\/ol>\n<p><center><img decoding=\"async\" class=\"alignnone \" src=\"https:\/\/user-images.githubusercontent.com\/13558917\/76364295-b4b1b280-631c-11ea-845f-fe0ff2e0a415.png\" width=\"348\" height=\"341\" \/><\/center><\/p>\n<h3><\/h3>\n<h3>4. Implement Image Classification Code for Xamarin.Android<\/h3>\n<p>Now that we&#8217;ve imported the model, it is time to write code.<\/p>\n<p>The completed\u00a0Image Classification sample app is available here on GitHub: <a href=\"https:\/\/github.com\/dhindrik\/MushroomDetector\/\">https:\/\/github.com\/dhindrik\/MushroomDetector\/<\/a><\/p>\n<p>In the <strong>Xamarin.Android<\/strong> project, add both <span class=\"lang:default decode:true crayon-inline \">ImageClassifcationModel.cs<\/span>\u00a0 and <span class=\"lang:default decode:true crayon-inline\">TensorflowClassifier.cs<\/span>:<\/p>\n<h3>ImageClassificationModel.cs<\/h3>\n<pre class=\"prettyprint\">public class ImageClassificationModel \n{ \n    public ImageClassificationModel(string tagName, float probability) \n    { \n        TagName = tagName; \n        Probability = probability; \n    } \n   \n    public float Probability { get; } \n    public string TagName { get; } \n}<\/pre>\n<h3>TensorflowClassifier.cs<\/h3>\n<pre class=\"lang:c# decode:true\">using System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing Android.App;\nusing Android.Graphics;\nusing Java.IO;\nusing Java.Nio;\nusing Java.Nio.Channels;\n\npublic class TensorflowClassifier\n{\n    \/\/FloatSize is a constant with the value of 4 because a float value is 4 bytes\n    const int FloatSize = 4;\n    \/\/PixelSize is a constant with the value of 3 because a pixel has three color channels: Red Green and Blue\n    const int PixelSize = 3;\n\n    public List&lt;ImageClassificationModel&gt; Classify(byte[] image)\n    {\n        var mappedByteBuffer = GetModelAsMappedByteBuffer();\n        var interpreter = new Xamarin.TensorFlow.Lite.Interpreter(mappedByteBuffer);\n\n        \/\/To resize the image, we first need to get its required width and height\n        var tensor = interpreter.GetInputTensor(0);\n        var shape = tensor.Shape();\n\n        var width = shape[1];\n        var height = shape[2];\n\n        var byteBuffer = GetPhotoAsByteBuffer(image, width, height);\n\n        \/\/use StreamReader to import the labels from labels.txt\n        var streamReader = new StreamReader(Application.Context.Assets.Open(\"labels.txt\"));\n\n        \/\/Transform labels.txt into List&lt;string&gt;\n        var labels = streamReader.ReadToEnd().Split('\\n').Select(s =&gt; s.Trim()).Where(s =&gt; !string.IsNullOrEmpty(s)).ToList();\n\n        \/\/Convert our two-dimensional array into a Java.Lang.Object, the required input for Xamarin.TensorFlow.List.Interpreter\n        var outputLocations = new float[1][] { new float[labels.Count] };\n        var outputs = Java.Lang.Object.FromArray(outputLocations);\n\n        interpreter.Run(byteBuffer, outputs);\n        var classificationResult = outputs.ToArray&lt;float[]&gt;();\n\n        \/\/Map the classificationResult to the labels and sort the result to find which label has the highest probability\n        var classificationModelList = new List&lt;ImageClassificationModel&gt;();\n\n        for (var i = 0; i &lt; labels.Count; i++)\n        {\n            var label = labels[i]; classificationModelList.Add(new ImageClassificationModel(label, classificationResult[0][i]));\n        }\n\n        return classificationModelList;\n    }\n\n    \/\/Convert model.tflite to Java.Nio.MappedByteBuffer , the require type for Xamarin.TensorFlow.Lite.Interpreter\n    private MappedByteBuffer GetModelAsMappedByteBuffer()\n    {\n        var assetDescriptor = Application.Context.Assets.OpenFd(\"model.tflite\");\n        var inputStream = new FileInputStream(assetDescriptor.FileDescriptor);\n\n        var mappedByteBuffer = inputStream.Channel.Map(FileChannel.MapMode.ReadOnly, assetDescriptor.StartOffset, assetDescriptor.DeclaredLength);\n\n        return mappedByteBuffer;\n    }\n\n    \/\/Resize the image for the TensorFlow interpreter\n    private ByteBuffer GetPhotoAsByteBuffer(byte[] image, int width, int height)\n    {\n        var bitmap = BitmapFactory.DecodeByteArray(image, 0, image.Length);\n        var resizedBitmap = Bitmap.CreateScaledBitmap(bitmap, width, height, true);\n\n        var modelInputSize = FloatSize * height * width * PixelSize;\n        var byteBuffer = ByteBuffer.AllocateDirect(modelInputSize);\n        byteBuffer.Order(ByteOrder.NativeOrder());\n\n        var pixels = new int[width * height];\n        resizedBitmap.GetPixels(pixels, 0, resizedBitmap.Width, 0, 0, resizedBitmap.Width, resizedBitmap.Height);\n\n        var pixel = 0;\n\n        \/\/Loop through each pixels to create a Java.Nio.ByteBuffer\n        for (var i = 0; i &lt; width; i++)\n        {\n            for (var j = 0; j &lt; height; j++)\n            {\n                var pixelVal = pixels[pixel++];\n\n                byteBuffer.PutFloat(pixelVal &gt;&gt; 16 &amp; 0xFF);\n                byteBuffer.PutFloat(pixelVal &gt;&gt; 8 &amp; 0xFF);\n                byteBuffer.PutFloat(pixelVal &amp; 0xFF);\n            }\n        }\n\n        bitmap.Recycle();\n\n        return byteBuffer;\n    }\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>That&#8217;s it! Now we can pass an image into <span class=\"lang:default decode:true crayon-inline \">TensorflowClassifier.Classify<\/span>\u00a0to retrieve our <span class=\"lang:default decode:true crayon-inline\">ImageClassificationModel<\/span>.<\/p>\n<h2>Learn More<\/h2>\n<p>Check out the links below:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/dhindrik\/MushroomDetector\/blob\/master\/MushroomDetector.Android\/TensorflowClassifier.cs\">Completed Code on GitHub<\/a><\/li>\n<li><a href=\"https:\/\/customvision.ai?WT.mc_id=aiapril-xamblog-bramin\">Azure Custom Vision Service<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/azure\/cognitive-services?WT.mc_id=aiapril-xamblog-bramin\">Azure Cognitive Services<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=pRDL5BtV_Fg&amp;feature=youtu.be\">The Community AI Show: Custom Vision, Xamarin and Simpsons<\/a><\/li>\n<li><a href=\"https:\/\/medium.com\/microsoftazure\/ai-april-content-dashboar-8e8cd6e8aa98\">Microsoft&#8217;s AI April<\/a><\/li>\n<li>\n<p class=\"title style-scope ytd-video-primary-info-renderer\"><a href=\"https:\/\/www.youtube.com\/watch?v=yDqvOsMRceo&amp;feature=youtu.be\"><span style=\"font-size: 12pt;\">App In The Cloud &#8211; Build an app powered by Custom Vision in Azure Cognitive Services<\/span><\/a><\/p>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Image Classification allows our Xamarin apps to recognize objects in a photo. This article will walkthrough how to implement using Azure&#8217;s Custom Vision Service, TensorFlow Lite\u00a0(an open source machine learning platform) and Xamarin.Android.<\/p>\n","protected":false},"author":579,"featured_media":46792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[313,1],"tags":[929,5,8350,867,8346,8347,8345,8354,3617,930,8348,8349,27,6988],"class_list":["post-46748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-xamarin","tag-ai","tag-android","tag-artificial-intelligence","tag-azure","tag-azure-custom-vision-service","tag-coreml","tag-custom-vision","tag-image-classification","tag-machine-learning","tag-ml","tag-tensorflow","tag-tensorflow-lite","tag-xamarin","tag-xamarin-android"],"acf":[],"blog_post_summary":"<p>Image Classification allows our Xamarin apps to recognize objects in a photo. This article will walkthrough how to implement using Azure&#8217;s Custom Vision Service, TensorFlow Lite\u00a0(an open source machine learning platform) and Xamarin.Android.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/46748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/579"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=46748"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/46748\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media\/46792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=46748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=46748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=46748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}