{"id":41336,"date":"2021-03-22T11:01:11","date_gmt":"2021-03-22T03:01:11","guid":{"rendered":"\/blog\/?p=41336"},"modified":"2021-03-22T11:01:15","modified_gmt":"2021-03-22T03:01:15","slug":"machine-learning-powered-inventory-tracking-with-raspberry-pi","status":"publish","type":"post","link":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/","title":{"rendered":"Machine Learning Powered Inventory Tracking with Raspberry Pi"},"content":{"rendered":"\n<p>In today&#8217;s tutorial, I will show you how to create a smart inventory tracker using object detection, powered by deep learning, with just a Raspberry Pi 4 and a camera. We will apply transfer learning on the YOLOv4 tiny model to identify custom objects, then use a simple python script to parse the model&#8217;s output to produce a count of each object. Finally, we will also integrate the application with Azure IoT Central so that we can monitor our inventory remotely and conveniently.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/aVTu11fNYijOogaQXWu-HoY_MqV6kdgXo2HWwQn6uSZSisxWh6amElYX55lWFdRbEBs08CnIOIH5dYdb09cqkNvGxyHVJwhUpuXnmI7dGT81NdwpeMqeKl98x14UUae1SdK0D7iA\" alt=\"\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Project Overview<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Have you ever passed by a grocery store but found yourself unsure of whether you needed to get that extra carton of milk? Well, what if there was some way to have eyes on the inside of our fridge to update us with that information? Today, with machine learning and IoT infrastructures, we are going to turn that convenience into reality.<\/p>\n\n\n\n<p>To summarize, we want to create two key features in our project. First, to automatically count the items in our fridge. Then, to be able to access the data remotely when we need it. Before we begin, let&#8217;s take a look at a short video demonstration below.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2021\/03\/SmartInventory-Demo-1.gif\" alt=\"\" class=\"wp-image-41534\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Machine Learning: Image Classification vs Object Detection<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Object recognition tasks like image classification and object detection are both performed with deep neural networks, but it is meaningful to differentiate between the two. In image classification, our input is an image that contains a single class. For example, we might have a photo of a single cat, or a dog, that we want the model to classify as a single output.<\/p>\n\n\n\n<p>In object detection, however, we want the model to not only identify multiple objects, but to also locate all the instances of each class present in a photo. Indeed, as opposed to classification, we will now be able to count the number of each type of object present in the frame &#8211; just what we need for this project!<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/ygwyoVpmXy0rtdafmWeBI3k5VM-fKX73ZE7KeW2sPGzvfyWzokSD16HI9HeqSoUIFaD9SbErQXZSuRA3fEnOc0t2xTrJF9VAvMJyDzNY8a8eSH2cYhP6aI1frP9LCKWrp8c3Ofv9\" alt=\"\" width=\"800\"\/><figcaption><em>Source: DataCamp<\/em><\/figcaption><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>For more information, Jason Brownlee&#8217;s <a href=\"https:\/\/machinelearningmastery.com\/object-recognition-with-deep-learning\/\">article<\/a> is a great introduction to the different types of computer vision tasks.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is Transfer Learning?<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Because computer vision tasks in general are considered complex tasks, it can take days to train a functional model even on a powerful GPU. Fortunately, as long as we have both the architecture and the weights, anyone can easily implement existing models that have already been trained.<\/p>\n\n\n\n<p>However, what if we want to train the model to recognise other things? After all, it&#8217;d be a farfetch to expect these models to naturally be great at recognising our household&#8217;s specific choice of grocery products. In this case, we don&#8217;t have to train a new model from scratch. Instead, we can apply transfer learning.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/nUbNSxXejpDUp-uc9Ym8LArsc5L3bnrpAmkj-RG4jwEnFxXl2NE4XDSBHqJCDG4CSTnlSNf3gr9pAYpfWAbJhcHZbS2VmhLqnNHoLEFMeKLbO_NuJSQhe7iPPBGxLYSW4ovKbTbV\" alt=\"\" width=\"800\"\/><figcaption><em>Source: <a href=\"https:\/\/datascience.aero\/transfer-learning-aviation\/\">datascience.aero<\/a><\/em><\/figcaption><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Transfer learning is a technique where we utilise a pretrained model, and train it with a new dataset with the objective of accomplishing a similar task. It allows us to achieve higher performance in our models with less data, while still drastically reducing the amount of time and resources required for training. Today, we will perform transfer learning with YOLOv4 Tiny.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is YOLO?<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>YOLO, which stands for You Only Look Once, is a state of the art neural network machine learning framework for object detection. When its first paper was released in 2015, it beat out the other models in inferencing speed, allowing for real time object detection at some expense of accuracy. Today, work on YOLO has continued under different parties to bring improvements in accuracy while retaining low latency.<\/p>\n\n\n\n<p>For today&#8217;s project, we are using the 4th version, <a href=\"https:\/\/arxiv.org\/abs\/2004.10934\">YOLOv4<\/a>. More specifically, we will be using the tiny version of YOLOv4, which has a smaller network size. While we do sacrifice some accuracy with a smaller model, this brings a reduction in the computing power requirements, allowing the model to be run with decent performance on an edge device like our Raspberry Pi.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prepare Your Custom Dataset<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>As our first step to train our custom model, we will have to build our dataset by gathering photos of the items that we want to detect. You&#8217;ll want at least 50 images of each class. In my project, I decided to count the number of milk cartons, eggs, and yoghurt packets, so my dataset should end up with at least 150 images in total.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Here are some tips when collecting your dataset.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>In general, capture images with a variety of lighting conditions and camera angles, and of the objects in different orientations to create a more robust dataset.<\/li><li>For objects that usually exist in multiples, such as eggs, be sure to include individual images as well as others in groups.<\/li><li>If you often stack some objects, like milk cartons, you&#8217;ll want to include several images where they are stacked so that our model can learn accordingly.<\/li><\/ul>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Label Dataset with labelImg<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/hO_zimkAgqR18hugfgXcphlzpcyg_rraei37Bwpeq53tTEVLGtHwoHh9hlGpqyNK7Zem113BkLazOxKE9cMhrWZW-x6mw5VJtqZcFkXlQ-b1hht3JyBev7ee1hYve4Jr_qg6lt2O\" alt=\"\" width=\"700\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>There are many open source tools for labelling images for computer vision projects. I&#8217;ve decided to go with <a href=\"https:\/\/github.com\/tzutalin\/labelImg\">labelImg<\/a>. It&#8217;s free, open source, and can be easily installed and run with the following two commands.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install labelImg\nlabelImg<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The GUI (graphical user interface) should open up and you can get to work labelling your images! Use <em>Open Dir<\/em> on the left pane to select the folder that your images are in. When they&#8217;re loaded in, use W and click-drag to begin drawing bounding boxes around your objects.<\/p>\n\n\n\n<p>Before saving each file, ensure that the export format is <strong>Pascal VOC<\/strong>, which should write to an xml file of the same name as the image. When you&#8217;re done, you should end up with a folder with a bunch of images and xml files, like I have below.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/dd6lhCeQMK45HbSGyd27cAXnta3w-YZXu949MS7p5oryjkgB40hRbcbUi3ryGlbwJsZYO_oW7jl7Jgiy7qsLX3VHk1J22ttBbuL-nO0DVVeHBiPFnyKM0nDrADivzfSz1pxv5iPq\" alt=\"\" width=\"700\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Process Labelled Data with RoboFlow<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We&#8217;ll first use Roboflow&#8217;s platform to augment our images. While we could do this ourselves programmatically, Roboflow offers some conveniences for later on. Augmentation is a technique in computer vision data processing where we apply transformations to our images through flipping, rotating, skewing, recolouring etc.<\/p>\n\n\n\n<p>This is very powerful, since each transformation essentially yields one new photo. If we create three augmented versions of each training sample, we would have 4 times the number of total samples! Besides, who has the patience to label 200 photos per class by hand?<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/QNlPn5mj2F2z9xLq7mufGgpt2bW5qIygLIgOb0N8UZA3qnmKNv9IMABXE4i7g-OA41rffYI0MmKqeZUXZxUuk_6myMEMBBKa-KF_imYltwSyxHFlsYZ-VycXAxYGIehdfgvTu7eE\" alt=\"\" width=\"600\"\/><figcaption><em>Source: Valentina Alto on Analytics Vidhya<\/em><\/figcaption><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To get started, first sign up for a Roboflow account <a href=\"http:\/\/roboflow.com\/\">here<\/a>. The free account has some limits, but will be sufficient for our project today. Once you&#8217;re logged in, create a new dataset for Object Detection (Bounding Box). You can name it whatever you like. I named mine &#8220;Groceries&#8221;, since it might be useful to generalise this dataset in the future.<\/p>\n\n\n\n<p>Then, drag and drop your image and xml files to upload them. Select &#8220;Finish Uploading&#8221; when you&#8217;re done, and let Roboflow split the data for you. Under Augmentation Options, add Flip Horizontal and Vertical, along with Rotation -15, +15. Under preprocessing, Auto-Orient and Resize should have been done automatically. If not, you can reference the screen capture that I have below.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/AR9ZYMqFVx-rFQGQjD8uULy5MKBOlVutnI7w1m436A8Y_Ao0hWf4k8jr22hqiXFokGpnVHNz361Ejw_sOXR8FT3HCyMcgHYjmGCmq9bUG4nix4BBOmxykV-UdCAZRfq4Iy-LMQSl\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>On the top right corner, click on Generate. Once done, select &#8220;YOLO Darknet&#8221; format and &#8220;show download code&#8221;. Then, you will be greeted with a !curl command. Save this for use in the later part of our tutorial.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Transfer Learning on Google Colab<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now it&#8217;s time to perform transfer learning! This section is based on <a href=\"https:\/\/blog.roboflow.com\/train-yolov4-tiny-on-custom-data-lighting-fast-detection\/\">Roboflow&#8217;s tutorial <\/a>and its accompanying Colab notebook, which performs transfer learning with a blood cell dataset.&nbsp;<\/p>\n\n\n\n<p>For this project, I made some minor changes to Roboflow&#8217;s notebook so that the code will run with the GPU provided to free Colab users by default. First save a copy of <a href=\"https:\/\/colab.research.google.com\/drive\/1ITXwVbIlequODsaaBY9AWc3CYI7i7PYY?usp=sharing\">my notebook<\/a> to your Google Drive so that you can make edits.<\/p>\n\n\n\n<p>In your copy, navigate to Edit &gt; Notebook Settings, and ensure that GPU is selected for hardware accelerator. Unless your GPU architecture is different for some reason, the only other change you have to make will be the first cell in the &#8220;Set up Custom Dataset for YOLOv4&#8221; section. Replace the last line with the curl command from the previous section.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code># Paste your link here\n%cd \/content\/darknet\n!curl -L &lt;YOUR LINK&gt; &gt; roboflow.zip; unzip roboflow.zip; rm roboflow.zip<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>For those curious, this notebook essentially automates the changes that we would need to make to the YOLOv4 Tiny architecture according to our dataset. The original step by step instructions can be found <a href=\"https:\/\/github.com\/AlexeyAB\/darknet\">here<\/a>, but they are long and can be confusing for beginners.<\/p>\n\n\n\n<p>Now, proceed to run the cells one by one. The training will take awhile, but before you head off for a break, take note that a reset of the Google Colab runtime will erase all the files created from the session. Yes &#8211; this includes the weights of the model!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Important! <\/strong>Once the training block is complete, be sure to grab the following before the runtime hits a timeout.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Save the best weights from content\/darknet\/backup\/custom-yolov4-tiny-detector_best.weights<\/li><li>Extract custom-yolov4-tiny-detector.cfg from content\/darknet\/cfg<\/li><\/ul>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The remaining three cells can be used to test our model on our test data. You can repeatedly run the last cell to pull a different random photo for the model to infer on.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>ML Inferencing on the Edge with Raspberry Pi<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now that we have our custom YOLOv4 tiny model, we can proceed to test it on our Raspberry Pi. To do that, we first have to set up our environment. Note: This tutorial uses Raspberry Pi OS.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Step 1<\/strong>: Clone AlexeyAB&#8217;s darknet repository on your Raspberry Pi and compile with make.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/AlexeyAB\/darknet<br>cd darknet<br>make<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Step 2: <\/strong>Edit the coco.names file under .\/darknet\/data\/coco.names. Using any text editor, replace the classes inside this file with your custom classes. In my case, it&#8217;s the following.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>Egg<br>Milk<br>Yoghurt<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Step 3: <\/strong>Place your saved weights from the Colab notebook inside the darknet\/backup folder, and the custom-yolov4-tiny-detector.cfg inside the darknet\/cfg folder.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Step 4:<\/strong> Place a test image of your choice named &#8220;test.jpg&#8221; in the darknet folder, and run the following command to test the model.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/darknet detect cfg\/custom-yolov4-tiny-detector.cfg backup\/custom-yolov4-tiny-detector_best.weights test.jpg -dont-show<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The results should then be shown in the command line interface. Great! You&#8217;ll notice that the time it takes for running the inference is quite long &#8211; over 7 seconds. Fortunately, since there&#8217;s no need to update the fridge&#8217;s inventory so frequently, this won&#8217;t be an issue.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/l5afZc1-B2MzAud8newSTyspDVBqdQyJrUyk3n2opzzmFLqih-eA6OZKzYQV8gfHUthz3Ggh1OL0zENZvvFK-gA0ozTMP9hZJr-nJVc2lRPhmN4l6yCSLU8uae2hbR41G9vSBLCT\" alt=\"\" width=\"700\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>A predictions.png file should also be generated in the darknet folder, so you can see the bounding boxes generated around each item.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/RpoQlJma5c-4j_p86kpK1scvEgZnJ1ISuKsJI68JiqlXtBPOE--1zYVb7rNVkzkSABKTx9Wm_ZuIo2dLYAl8OG0l3kk-UjKXJTIQyD2l-VSd4gMRBlvJ4GHvy4JVTfKKBMvvCOAQ\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Deploy on Microsoft Azure IoT Central<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Of course, what we&#8217;ve done so far wouldn&#8217;t be very useful if we couldn&#8217;t access this data remotely. The next step of our project is to create an Azure IoT Central Application where we will periodically send our inventory status, so that we can monitor it remotely. Before proceeding, create a free Microsoft Azure account <a href=\"https:\/\/azure.microsoft.com\/en-gb\/free\/\">here<\/a>.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Create an Azure IoT Central application<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Head over to <a href=\"https:\/\/apps.azureiotcentral.com\/\">Azure IoT Central<\/a>. Scroll down and select <em>Create a custom ap<\/em>p. You will be prompted to log in before being shown the screen below. Choose an application name and URL, and leave the Application template as Custom application. Under pricing plan, select free for now. Then, proceed to create your application.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/9BjSm8G2nJlkHO38H9dAQ_yJvujGhXkqkuOxQs4sbo6P4moSJ1X4yg7bcnWy0h3YqqnpwBEV9mBy5DmIH0pDbo-bbNf2Cuoa_rtuG0hmyAMSdCCcIGU0r5hSDQ5WIuM59Se1r4hM\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Add a Device Template<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Using the sidebar, navigate to <em>Device template<\/em>, then click on <em>+New<\/em>. From there, select <em>IoT device<\/em> then <em>Next: Customize<\/em>. From here, select a device template name &#8211; I went with \u201cRaspberryPi\u201d. Then, proceed to create the template.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/N-HxX8wYqJVMpogCpjkaELRJfrpNfQyakzxbCgY2fW9gQUu8HH5tip7hhPnud_DpL_rDKmmmYAYyoS1eIEOAij9G-4EanBkrdM1exxK86F5P8ukZ79gw8XvzjYpGcH1nTGvGBUvR\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Add Interface &amp; Capabilities to Device Template<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Following the previous step, you should have been taken automatically to your new device template. Select <em>Custom model<\/em>, then <em>Add an inherited interface<\/em>. Once again, select <em>custom<\/em>.<\/p>\n\n\n\n<p>After that, you will need to add capabilities to your interface according to the items that you are keeping track of. Be sure that these are the right parameters that you want, as they can&#8217;t be changed after we publish our device template. Click on save, but do not publish for now.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/qBPLBf728krqdQQgLyFz5-Ua2cKi0Ksgt8g0a683GGhffKqV7hErRm78SmS5XvmEsHfDNgJg_2QTC6t-XkvA7a6K9z_aCgVwEQn0EwqSoUzaLullTm8gzNtkvTH8ltTVBBJN8PFB\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Set Up Device View<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To visualise our data nicely on our Azure IoT Central application, we have to set up our device view. Navigate to Views on the device panel and select <em>Visualizing the device<\/em>.<\/p>\n\n\n\n<p>Following this, under the Edit view pane, click on <em>Select a Telemetry<\/em>. Choose your first item and click <em>Add tile<\/em>. The tile should appear on your dashboard preview on the right. For each of the tiles, change their display value to \u201clast known value\u201d.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/AtjW23w-hIegZ2owe6T1vbXW-P9EIEEs-beqDa0mRglCaZn1571smMT_6GYq8Ond60k97meQ2XxZZpYS4ruGQ4JMLeERh5qhziPFLJRdBH_Ck1SG1i3GBSlRILYLhWoDROPuVsZi\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>I added three tiles for a total of three items, ending up with the dashboard shown below. Once you are satisfied with your settings, click on <em>Publish<\/em> at the top of the page.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/xgHjhtZgg5qoSVtfys6ndngC2VwyaerVTywvjXlB57zEO-ZfwCj2x_7D_6z3LqMda9RkyD3bJ00-NdpsodHeRDVzJSBUVv0NSgxrwYBs7CpThfY1ckoW_mAczoYqDuMNMP-TlAwb\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 5: Create a Device<\/strong><\/h2>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now, we have to create a device. Navigate to Devices and click on + New. Enter a device name of your choice, and remember to select the device template that you created previously. I went with &#8220;Rpi&#8221;.<\/p>\n\n\n\n<p>Click into the device you just created. You should see the dashboard that you set up earlier, but without any data shown. We\u2019ll fix that in a moment by getting our Raspberry Pi to send some data to our Azure IoT Central application. Click \u201cConnect\u201d on the top right of the screen and a window should pop up.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/I2gjfw1HxHhrS0TJzwVPUeUD91Gs-vW-LWYK38WjPmaJD9bR_Ngc7CIdb4W6CjtT8RRWVcawbBSi-_1pDmsGElKPZ6d1N3wouja4eKDHG1ZRs_zvmhY_DYxLXzU3Q4E8Cw1db_6U\" alt=\"\" width=\"600\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 6: Generate Connection Key<\/strong><\/h2>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Open this <a href=\"https:\/\/dpsgen.z8.web.core.windows.net\/\">Azure IoT Central Connection String Generator<\/a> in a new browser window. Fill the blanks in with the corresponding data from the window above. Take note that \u201cDevice Key\u201d refers to the primary key. Finally, record down the connection string that is generated for later.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 7: Set Up Raspberry Pi for Azure IoT<\/strong><\/h2>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>As a final step, run the following command on your Raspberry Pi CLI to install the related packages for Azure IoT.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo pip3 install azure-iot-device azure-iot-hub azure-iothub-service-client azure-iothub-device-client<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Running Through the Complete Workflow<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We&#8217;ve been working with bits and pieces so far, but it&#8217;s finally time to put it all together to create our machine learning powered Smart Fridge Inventory Tracker. Before following with these steps, first visit my Github repository <a href=\"https:\/\/github.com\/supperted825\/RPi_SmartInventoryTracker\">here<\/a> and download the files as a ZIP. Place <em>img.txt<\/em> and <em>parseSendData.py<\/em> into your darknet folder.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1.&nbsp; Take a Photo<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>First, we take a photo with the camera attached to the Raspberry Pi using the command \u2026 . The file is saved to the darknet folder as img.jpg.<\/p>\n\n\n\n<p>For the Raspberry Pi Camera module, use the following. Ensure that the camera is enabled via raspi-config &gt; Interface first.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>raspistill -o \/darknet\/img.jpg<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If you are using a USB webcam like me, first install the fswebcam package, then we can take photos in a similar manner. The second command takes a photo and writes it to the darknet folder as img.jpg with a specific delay, frameskip and resolution. You can adjust them to your preference.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install fswebcam<br>fswebcam -D 2 -S 20 -r 1920x1080 --no-banner darknet\/img.jpg<\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2.&nbsp; Run &amp; Record the Inference Results<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To parse the data and send it to Azure IoT Central, we will need to get the model\u2019s output in a text file. We use the following command to read in the files listed in img.txt (only img.jpg), perform object detection, and write the output to result.txt.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/darknet detector test cfg\/coco.data cfg\/custom-yolov4-tiny-detector.cfg backup\/custom-yolov4-tiny-detector_best.weights -dont_show -ext_output &lt; img.txt &gt; result.txt<\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3.&nbsp; Parse &amp; Send Data to Azure IoT Central<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now, open parseSendData.py. This is a simple Python script that will parse the result.txt file, count the instances of each class and then send it to Azure IoT Central. First, replace the CONNECTION_STRING with the one you obtained in Step 12 of the previous section.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>CONNECTION_STRING = &lt;Replace with your own string&gt;<\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Then, update the dictionary by replacing the keys with your item classes. Please note that you must match the string for each class according to what you have written in the coco.data file previously. Otherwise, you will encounter a key error.<\/p>\n\n\n\n<p>Now, run the python script through your command line with the following:<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 &lt;yourpath&gt;\/parseSendData.py<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If all goes well, you should see something similar to the following output, and the script will complete without errors.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>Attempting to Send Messages to Azure IoT<br>Sending message: {'Egg': 6, 'Milk': 1, 'Yoghurt': 2}<br>Message Sent<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Head back to your device view on Azure IoT Central. The numbers should show up in a few moments!<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/EWVVG1eAkzFx1rFNTqtJ89SLKiaI2K7Vq5_-XHjLn18tsEtkEzk235ggCQHQNt63_kxTc_E5ZQHuimdRVDAISCJBhe26bvBwtxDfwsc3QJXz_CVpIzKKhwBn38SBn9wKYrCPfZOB\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:16px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Automate the Workflow<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The last step that we need to do is to automate the entire process of the previous section with a bash script. Fortunately, we can use <a href=\"https:\/\/www.raspberrypi.org\/documentation\/linux\/usage\/cron.md\">cron<\/a> to schedule the entire process to run automatically at half-an-hour intervals on our Raspberry Pi.<\/p>\n\n\n\n<p>First, we create a bash script titled &#8220;workflow.sh&#8221; as follows in our darknet folder. A bash script is essentially a list of console commands that can be run together in a group, so they don&#8217;t have to be run individually. Later on, we will use cron to execute this script automatically.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>fswebcam -D 2 -S 20 -r 1920x1080 --no-banner img.jpg<br>.\/darknet detector test cfg\/coco.data cfg\/custom-yolov4-tiny-detector.cfg backup\/custom-yolov4-tiny-detector_best.weights -dont_show -ext_output &lt; img.txt &gt; result.txt<br>python3 parseSendData.py<\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Then, we make the script executable by running the following command. Make sure that your present working directory is the darknet folder, where the script is located.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x workflow.sh<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now, if you run the script, you should see the entire workflow occur automatically and consecutively in your terminal output. Our program will take the photo, run the model, parse the data and upload it to Azure IoT Central with just one execution. Neat!<\/p>\n\n\n\n<p>To schedule the execution of this script with cron, first open the crontab editor by running the command below. Cron is preinstalled with Raspberry Pi OS.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -e<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>You will be prompted to select an editor. If you don&#8217;t know which to choose, pick the simple nano editor (the first option). Then, a file will open in your command line. We have to add our scheduled command to this file for it to run automatically. At the bottom of the file, add the following.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>*\/30 * * * * \/home\/pi\/darknet\/workflow.sh<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>And that&#8217;s it! Get your Raspberry Pi and camera in position, and you should see the data flow into your Azure IoT Central application at the next half-hour mark.<\/p>\n\n\n\n<div style=\"height:14px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Thanks for reading! I hope this article was helpful in the creation of your smart inventory tracking project. It&#8217;s amazing how accessible it has become to build a machine learning application for personal use. With IoT and cloud integration, these applications are even more useful in meeting practical needs.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>For more projects involving machine learning on the edge, feel free to have a look at the below:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/01\/19\/tiny-ml-with-wio-terminal-1-intro\/\">Learn TinyML using Wio Terminal and Arduino IDE #1 Intro<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/02\/03\/learn-tinyml-using-wio-terminal-and-arduino-ide-2-audio-scene-recognition-and-mobile-notifications\/\">Learn TinyML using Wio Terminal and Arduino IDE #2 Audio Scene Recognition and Mobile Notifications<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/02\/26\/tinyml-with-wio-terminal-3-people-counting-and-azure-iot-central-integration\/\">TinyML with Wio Terminal #3 People Counting and Azure IoT Central Integration<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/02\/23\/build-a-tinyml-smart-weather-station-with-wio-terminal\/\">Build a TinyML Smart Weather Station with Wio Terminal<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/02\/handwriting-recognition-with-wio-terminal-edge-impulse\/\">Build Handwriting Recognition with Wio Terminal &amp; Edge Impulse<\/a><\/li><\/ul>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s tutorial, I will show you how to create a smart inventory tracker using<\/p>\n","protected":false},"author":3537,"featured_media":41531,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[1301,3254,2799,1302,3737,247,1450,2805,2378],"class_list":["post-41336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-ai","tag-computer-vision","tag-edge-ai","tag-edge-computing","tag-object-detection","tag-raspberry-pi","tag-raspberry-pi-4","tag-raspberry-pi-camera","tag-raspberry-pi-projects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Machine Learning Powered Inventory Tracking with Raspberry Pi - Latest News from Seeed Studio<\/title>\n<meta name=\"description\" content=\"Create your very own smart inventory tracker with your Raspberry Pi and any camera, using object detection powered by machine learning!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Machine Learning Powered Inventory Tracking with Raspberry Pi - Latest News from Seeed Studio\" \/>\n<meta property=\"og:description\" content=\"Create your very own smart inventory tracker with your Raspberry Pi and any camera, using object detection powered by machine learning!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/\" \/>\n<meta property=\"og:site_name\" content=\"Latest News from Seeed Studio\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-22T03:01:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-22T03:01:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png\" \/>\n\t<meta property=\"og:image:width\" content=\"3000\" \/>\n\t<meta property=\"og:image:height\" content=\"1750\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jonathan Tan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan Tan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/\",\"name\":\"Machine Learning Powered Inventory Tracking with Raspberry Pi - Latest News from Seeed Studio\",\"isPartOf\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png\",\"datePublished\":\"2021-03-22T03:01:11+00:00\",\"dateModified\":\"2021-03-22T03:01:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094\"},\"description\":\"Create your very own smart inventory tracker with your Raspberry Pi and any camera, using object detection powered by machine learning!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#primaryimage\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png\",\"contentUrl\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png\",\"width\":3000,\"height\":1750},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.seeedstudio.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Machine Learning Powered Inventory Tracking with Raspberry Pi\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/\",\"name\":\"Latest News from Seeed Studio\",\"description\":\"Emerging IoT, AI and Autonomous Applications on the Edge\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094\",\"name\":\"Jonathan Tan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g\",\"caption\":\"Jonathan Tan\"},\"url\":\"https:\/\/www.seeedstudio.com\/blog\/author\/jonathan-tan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Machine Learning Powered Inventory Tracking with Raspberry Pi - Latest News from Seeed Studio","description":"Create your very own smart inventory tracker with your Raspberry Pi and any camera, using object detection powered by machine learning!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/","og_locale":"en_US","og_type":"article","og_title":"Machine Learning Powered Inventory Tracking with Raspberry Pi - Latest News from Seeed Studio","og_description":"Create your very own smart inventory tracker with your Raspberry Pi and any camera, using object detection powered by machine learning!","og_url":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/","og_site_name":"Latest News from Seeed Studio","article_published_time":"2021-03-22T03:01:11+00:00","article_modified_time":"2021-03-22T03:01:15+00:00","og_image":[{"width":3000,"height":1750,"url":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png","type":"image\/png"}],"author":"Jonathan Tan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jonathan Tan","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/","url":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/","name":"Machine Learning Powered Inventory Tracking with Raspberry Pi - Latest News from Seeed Studio","isPartOf":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#primaryimage"},"image":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#primaryimage"},"thumbnailUrl":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png","datePublished":"2021-03-22T03:01:11+00:00","dateModified":"2021-03-22T03:01:15+00:00","author":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094"},"description":"Create your very own smart inventory tracker with your Raspberry Pi and any camera, using object detection powered by machine learning!","breadcrumb":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#primaryimage","url":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png","contentUrl":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png","width":3000,"height":1750},{"@type":"BreadcrumbList","@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/03\/22\/machine-learning-powered-inventory-tracking-with-raspberry-pi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.seeedstudio.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Machine Learning Powered Inventory Tracking with Raspberry Pi"}]},{"@type":"WebSite","@id":"https:\/\/www.seeedstudio.com\/blog\/#website","url":"https:\/\/www.seeedstudio.com\/blog\/","name":"Latest News from Seeed Studio","description":"Emerging IoT, AI and Autonomous Applications on the Edge","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094","name":"Jonathan Tan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g","caption":"Jonathan Tan"},"url":"https:\/\/www.seeedstudio.com\/blog\/author\/jonathan-tan\/"}]}},"modified_by":"Jonathan Tan","views":15903,"featured_image_urls":{"full":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png",3000,1750,false],"thumbnail":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-80x80.png",80,80,true],"medium":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-300x175.png",300,175,true],"medium_large":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-768x448.png",640,373,true],"large":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-1030x601.png",640,373,true],"1536x1536":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-1536x896.png",1536,896,true],"2048x2048":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-2048x1195.png",2048,1195,true],"visody_icon":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover.png",32,19,false],"magazine-7-slider-full":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-1536x1020.png",1536,1020,true],"magazine-7-slider-center":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-936x897.png",936,897,true],"magazine-7-featured":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-1024x597.png",1024,597,true],"magazine-7-medium":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-720x380.png",720,380,true],"magazine-7-medium-square":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/03\/Cover-675x450.png",675,450,true]},"author_info":{"display_name":"Jonathan Tan","author_link":"https:\/\/www.seeedstudio.com\/blog\/author\/jonathan-tan\/"},"category_info":"<a href=\"https:\/\/www.seeedstudio.com\/blog\/category\/news\/\" rel=\"category tag\">News<\/a>","tag_info":"News","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/41336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/users\/3537"}],"replies":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/comments?post=41336"}],"version-history":[{"count":10,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/41336\/revisions"}],"predecessor-version":[{"id":41536,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/41336\/revisions\/41536"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media\/41531"}],"wp:attachment":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media?parent=41336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/categories?post=41336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/tags?post=41336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}