<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Valentin on Medium]]></title>
        <description><![CDATA[Stories by Valentin on Medium]]></description>
        <link>https://medium.com/@valentin.philipp?source=rss-79cffa5c57d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DAFD1qO4mFaCl4ACL4_OEg.png</url>
            <title>Stories by Valentin on Medium</title>
            <link>https://medium.com/@valentin.philipp?source=rss-79cffa5c57d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:38:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@valentin.philipp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Reduce Training Data with Self-Supervised Learning]]></title>
            <link>https://medium.com/picsellia/how-to-reduce-training-data-with-self-supervised-learning-d1a7aacc6bb5?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1a7aacc6bb5</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[image-augmentation]]></category>
            <category><![CDATA[data-augmentation]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Thu, 28 Jul 2022 11:57:29 GMT</pubDate>
            <atom:updated>2022-07-29T11:40:36.866Z</atom:updated>
            <content:encoded><![CDATA[<h3>Label Less Data And Get Same Model Performance with Self-Supervised Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HhF0GFvQVkEFYx8w.png" /></figure><h3>Introduction and Motivation</h3><p>Deep Neural Networks such as Deep CNNs are excellent feature extractors. That’s why they have gained a top spot in many visual tasks. Visual Transformers (ViT) are pushing the limits even further. However, their success is largely attributed to Supervised Learning and the immense amount of training data from datasets like ImageNet, Places, Kinetics, etc.</p><p>However, collection and annotation of large-scale Image/Video datasets are very time-consuming and quite expensive, not to mention that there is not often enough unlabelled material to annotate (e.g., Medical Imaging). As a reference, the Places dataset consists of 2.5 million labeled images, ImageNet 1.3 million. At the same time, Kinetics is a labeled video dataset comprising around 500K videos, each with a duration of about 10 seconds.</p><p>With this motivation, Self-Supervised Learning (SSL) aims to leverage large <strong>unlabeled datasets </strong>to train capable feature extractors such as CNN or ViT encoders. Those are later used with smaller labeled datasets to train networks on a task of choice, using fewer data. Self-supervised learning derives from unsupervised learning. It aims at learning rich representations and semantically meaningful features from unlabeled data. In other words, SSL is a learning method in which you can train Networks with <strong>automatically generated labels </strong>produced from unlabeled datasets.</p><h3>What is Self-Supervised Learning?</h3><p>Simply put, Self-Supervised Learning refers to learning methods in Machine Learning that make use of automatically generated labels that originate from large unlabelled datasets. It offers very good performance without the need for large labelled datasets.</p><h3>Key Concepts in Self-Supervised Learning</h3><p>Before we explain how Self-Supervised Learning (SSL) works and how you can leverage it to reduce the training data, it’s best to explain some key concepts.</p><ul><li><strong>Human-annotated labels</strong> are labels of data that human annotators manually create. These are the typical labels used in classic Supervised Learning.</li><li><strong>Pseudo-labels </strong>refer to automatically generated labels that data scientists use to train the feature extraction network, commonly called “Encoder,” on some pretext task. For example, we could randomly rotate images by 0°, 90°, 180°, or 270° and assign the labels 0,1,2,3, respectively, depending on the rotation. It’s possible to create these labels without any human assistance!</li><li><strong>Pretext tasks </strong>are pre-designed tasks that act as an essential strategy to learn data representations using pseudo-labels. Its goal is to help the model discover critical visual features of the data. Common pretext tasks include geometrical/color transformations and context-based tasks such as solving jigsaw puzzles. For example, a pretext task could be classifying an augmented image either as rotated by 0°, 90°, 180°, or 270°.</li><li><strong>Downstream tasks</strong> are application-specific tasks that utilize the knowledge learned during the pretext task. They are chosen by the developer depending on the application’s end goal. Examples include classification, object detection, semantic segmentation, and action recognition.</li></ul><h3>The Self-Supervised Framework</h3><p>Now that we have introduced the core concepts, let’s combine them to understand the Self-Supervised Learning workflow. Figure 1 offers a visual illustration. Very briefly, SSL aims at transforming an unsupervised task into a supervised task (pretext task) through automatically generated labels (pseudo-labels). Then it transfers the knowledge acquired from the pretext task to solve the final task (downstream task).‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RDTxGIkeKNkK_Gt7.png" /><figcaption>Fig. 1: Self-Supervised Learning workflow. Source <a href="https://arxiv.org/pdf/2011.00362.pdf">[3]</a></figcaption></figure><p>Assume an Encoder model (CNN, ViT) has already been designed. Also, let’s assume that we have a large image dataset at our disposal, with only a small percentage of it annotated. We begin by choosing a pretext task, such as recreating occluded parts, solving a Jigsaw puzzle, and rotation classification. Once we pick a pretext task, data augmentation takes place. This data augmentation serves a different purpose than supervised learning tasks. Here, augmentation aims to map an image into different views via stochastic transformations to create the pretext task. For example, for the pretext task of image recreation (inpainting), augmentation will randomly mask other parts of the image, and the Encoder aims to recreate these occluded parts. Pseudo-labels are created through this augmentation automatically.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bIlB02IQOwoqXwgJ.png" /><figcaption>Fig. 2: Common pretext tasks. Source <a href="https://www.mdpi.com/1099-4300/24/4/551/htm">[4]</a></figcaption></figure><p>This data augmentation process encourages the network to learn hidden representations through solving the pretext task. Augmentations of the same input have more similar latent representations compared to other inputs, helping the Encoder discover the dominant features.</p><p>Moving on, the Encoder is trained on the pretext task, which is usually quite different from the downstream task. If the Encoder successfully solves the pretext task, it must have learned to extract the essential features from the images and avoid paying much attention to the noise. Otherwise, it wouldn’t be able to solve these complicated tasks. However, the complexity of the data augmentation, or pretext task, must challenge the model. Otherwise, if the model solves the task very quickly, it might not have been learned, and the complexity may be low.</p><p>Once the Encoder successfully solves the pretext task with sufficient accuracy, its parameters are used as an initialization for the network that aims to solve the downstream task. Adding more layers on top of the encoder part is not unusual, which are trained solely using supervised learning. During the downstream task training, the labeled portion of the dataset is used. Hence, the network now relies on traditional supervised training to solve the final task.</p><p>Essentially, we transfer the knowledge acquired during the pretext task training down to the downstream task, similar to the well-known Transfer Learning technique but with some important differences.</p><h3>How To Reduce Training Data Via Self-Supervision</h3><p>In figure 3, source [5], we observe a graph depicting the test-set accuracy on the CIFAR-10 dataset vs. the number of training examples used. The plot compares a traditional supervised training method against a self-supervised method that uses rotation classification as the pretext task. The comparison begins from as low as 20 training examples and moves up to 5000 training examples. It is clear that for a low number of training examples, e.g., &lt;1000, Self-Supervised Learning significantly outperforms Supervised learning. The lower the number of training data, the bigger the gain is. However, around 2000 training examples, we see a crossover; afterward, supervised learning achieves superior performance. These numbers are a rough guideline and will vary depending on the application. Still, the general rule of thumb is that SSL will outperform Supervised Learning by a large margin when training data is scarce.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*MCpOZZtnmG1syXOi.jpeg" /><figcaption>Fig.3: The impact of training examples on accuracy for Supervised and Self-Supervised Learning. The X axis is in Log scale. Graph inspired by Source <a href="https://arxiv.org/pdf/1803.07728.pdf">[5]</a></figcaption></figure><p>Let’s recreate a similar real-world case study. You, as an ML engineer, have been asked to create a semantic segmentation computer vision model to identify certain microorganisms in microscopy images. The scientists have provided you with 3000 images of unlabeled data. You explain that to solve the problem efficiently, you need annotated data. They argue that this is a quite time-consuming and expensive activity, since domain experts must spend time on the task. They suggest that annotating 500 images will require around one month.</p><p>So, to speed up the deployment of the model, you accept to move on with 500 images at first. You suspect that 500 images will not be enough for supervised training. You try it, and indeed, the model achieved a low performance with visible signs of overfitting that are not solved with regularization methods. Then, you search for pre-trained models on a similar dataset but fail to find something relatable to the architectures that you plan to test, so Transfer Learning is not a good option. This way, everything naturally leads to Self-Supervised Learning. Now, you can leverage the 500 annotated images (except the test set, of course)<strong> and the remaining 2500 unlabeled images.</strong></p><p>Not only can you design a more accurate model with much less training data, but you can later deploy this model as an annotation assistant to the scientists to speed up the labeling process of the remaining images. If your annotated dataset becomes quite large, at some point, you can retrain the model with Supervised Learning to further increase accuracy. <a href="https://www.picsellia.com/post/feedback-loops-and-versioning-in-computer-vision">Feedback loops</a> will also provide another means of increasing accuracy even more.</p><h3>Self-Supervised Learning (SSL) vs. Transfer Learning (TL)</h3><p>Both techniques rely on knowledge transfer through parameter initialization and are excellent ways to reduce the amount of training data needed. However, they also share some significant differences.</p><ol><li>Transfer Learning relies on a supervised learning framework during both the pre-training and the training phase, while SSL does not use supervised learning during pre-training.</li><li>You can’t use TL on the same dataset since it wouldn’t make sense. On the other hand, using SSL on the same dataset can significantly improve performance (test set must be set apart!).</li></ol><p>Depending on the use case, you may want to pick one over the other. To help you decide which one is best, some research insights are:</p><ul><li>When the domain difference between the source and target tasks is large, SSL outperforms TL. For instance, using ImageNet initialization TL for medical imaging is not a good option.</li><li>SSL is less sensitive to domain differences between the source and the target task than TL.</li><li>Given a source task, SSL usually outperforms TL when the pre-training data is too scarce.</li><li>If the class imbalance is prevalent in a dataset, we recommend SSL since it is more robust against imbalances than TL.</li></ul><h3>References</h3><p>[1] Yahui Liu, Enver Sangineto, Wei Bi, Nicu Sebe, Bruno Lepri, Marco De Nadai. <a href="https://openreview.net/pdf?id=AJofO-OFT40">Efficient Training of Visual Transformers with Small Datasets</a></p><p>[2] Longlong Jing and Yingli Tian, <a href="https://arxiv.org/pdf/1902.06162.pdf">Self-supervised Visual Feature Learning with Deep Neural Networks: A Survey</a>.</p><p>[3] Ashish Jaiswal, Ashwin Ramesh Babu, Mohammad Zaki Zadeh, Debapriya Banerjee, Fillia Makedon. <a href="https://arxiv.org/pdf/2011.00362.pdf">A SURVEY ON CONTRASTIVE SELF-SUPERVISED LEARNING</a>.</p><p>[4] Saleh Albewi, <a href="https://www.mdpi.com/1099-4300/24/4/551/htm">Survey on Self-Supervised Learning: Auxiliary Pretext Tasks and Contrastive Learning Methods in Imaging</a>.</p><p>[5] Spyros Gidaris, Praveer Singh, Nikos Komodakis, <a href="https://arxiv.org/pdf/1803.07728.pdf">UNSUPERVISED REPRESENTATION LEARNING BY PREDICTING IMAGE ROTATIONS.</a></p><blockquote><em>Originally posted by </em><a href="https://medium.com/@poulinakis.kon"><em>Konstantinos Poulinakis</em></a><em> for https://</em><a href="http://www.picsellia.com/"><em>www.picsellia.com</em></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1a7aacc6bb5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/how-to-reduce-training-data-with-self-supervised-learning-d1a7aacc6bb5">How to Reduce Training Data with Self-Supervised Learning</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is Image Data Augmentation and Why Use It?]]></title>
            <link>https://medium.com/picsellia/what-is-image-data-augmentation-and-why-use-it-8bb99e4f54a1?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bb99e4f54a1</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[data-augmentation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[image-augmentation]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Mon, 18 Jul 2022 17:19:01 GMT</pubDate>
            <atom:updated>2022-07-21T13:52:53.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*JG15HNzI2Tp3dWIQgmzwNw.png" /></figure><p><strong>Table of contents</strong></p><ol><li><a href="#ea14">What Is Image Data Augmentation?</a></li><li><a href="#775d">Why Use Data Augmentation in Computer Vision?</a></li><li><a href="#7aa2">Overfitting — What, Why, &amp; When?</a></li><li><a href="#612f">Best Image Augmentation Techniques for Computer Vision</a></li><li><a href="#ebae">Takeaways</a></li></ol><p>You had a groundbreaking idea for a machine learning (ML) project and found a great dataset online. You train this data using state-of-the-art ML techniques and produce promising results in your first run.</p><p><em>But something seems off.</em></p><p>Your model seems to struggle when you deploy it in production. When faced with real-world data, the performance is not what you expected.</p><p>Problems arise when your data is insufficient, and your model cannot extract adequate information. Moreover, many open-source datasets are tiny because data collection is tedious and frustrating.</p><p>To solve the problem of data scarcity, we use data augmentation techniques. Data augmentation allows engineers to generate new samples of data from the original data used to train the model. Data augmentation has become necessary in any Deep Learning training <a href="https://www.picsellia.com/post/what-is-mlops-and-why-its-important">pipeline</a> and has proven to be particularly helpful in the case of computer vision (CV).</p><p>But how do you augment image data? Let’s discuss the process in detail.</p><h3>What Is Image Data Augmentation?</h3><p>Image data augmentation is the process of generating new transformed versions of images from the given image dataset to increase its diversity.</p><p>To a computer, images are just a 2-dimensional array of numbers. These numbers represent pixel values, which you can tweak in many ways to generate new, augmented images. These augmented<em> </em>images resemble those already present in the original dataset but contain further information for better generalization of the machine learning algorithm.</p><p>In a CVOps pipeline, image data augmentation is beneficial for improving the performance of object detection, classification, or segmentation models. More on this in the next section.</p><h3>Why Use Data Augmentation in Computer Vision?</h3><p>For deployable computer vision solutions, more extensive datasets are preferable; datasets that cover all visual aspects of a target object. But this is easier said than done.</p><p>Image data collection requires manual capturing and annotations of images, and it is impossible to capture every single scenario that may be useful for the computer vision model.</p><p>Say you want to collect images of scenic landscapes for a CV project. It is not humanly possible to capture pictures in all lighting conditions. No matter how hard you try, your dataset will always have some information missing, which limits the ability of your CV model to learn, and the final output might not be as expected. Data augmentation techniques can help create new images to fill in this missing data.</p><p>Image data augmentation saves several person-hours that would otherwise be spent trying to build the perfect dataset. It allows you to improve your model’s performance using your existing dataset by protecting it from <em>overfitting.</em></p><p>We just introduced a new term there; let’s talk more about overfitting.</p><h3>Overfitting–What, Why, &amp; When?</h3><p>A common problem with underperforming machine learning models is overfitting.</p><p>When your model has an excellent training score but fails to perform on real-world test data, the model is said to have <em>over-fitted</em>.</p><p>To explain it further, modern machine learning models can learn discreet underlying patterns with high precision. They can perform very well on data they have seen, but the model may not be able to distinguish similar patterns from unseen examples. It is so used to seeing the training examples that it cannot develop familiarity with new data points.</p><p>Typically, overfitting occurs when you have a small dataset. A small dataset means your machine learning model has only a limited number of patterns available for learning.</p><p>Let’s say you want to build a cat classifier, but you only have images of black cats. The model might never fail to identify a black cat, but it will struggle for cats of different colors and breeds. The same would be the case if the images captured are all from the same angle; the model will demonstrate poor performance if your test image is from a changed perspective.</p><p>Luckily there are multiple solutions available for such a problem. Computer vision researchers have developed several augmentation techniques to extend a dataset and improve model performance.</p><p>Let’s discuss these image augmentation techniques in detail.</p><h3>Best Image Augmentation Techniques for Computer Vision</h3><p>Image data is perhaps one of the easiest to augment due to the wide-ranging availability of relevant techniques. This plethora of augmentation techniques performs very well for computer vision tasks. Some of these include:</p><ul><li><strong>Position Manipulation</strong>:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O_VNNyk9XWBTXMjR" /></figure><p>You can change the position of the image in many different ways. Position manipulation methods include:</p><ul><li><strong>Scaling: </strong>Increase or decrease the size of the picture.</li><li><strong>Rotation: </strong>Rotate the image to generate new angles.</li><li><strong>Flipping: </strong>Flip the image left, right, or upside down.</li><li><strong>Color Manipulation:</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L67Y9mBB41jIelhD" /></figure><p>The colors of an image hold vital information for the machine learning models. We can change these colors for different effects. Examples of such tweaks are:</p><ul><li>Brightness</li><li>Contrast</li><li>Saturation</li><li>Hue</li></ul><p>Changing the above settings can help us create different lighting conditions. These modified images can be helpful in situations like the one discussed in the section “<em>Why Use Data Augmentation in Vision?</em>”.</p><ul><li><strong>Image Manipulation:</strong></li></ul><p>You can manipulate images in multiple ways to synthesize data representing different situations. We can use the following techniques for image augmentation:</p><ul><li><strong>Blur: </strong>Images can be blurred using different kernel configurations depending on the amount of blur required. Blur allows us to generate pictures with varying levels of focus and degraded image quality.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uwup9CqoqhsUJlPX" /></figure><ul><li><strong>Sharpening: </strong>Sharpness has the opposite effect on an image compared to blur, but it serves the same purpose; to get different levels of focus and higher image clarity.</li><li><strong>Random cropping: </strong>Randomly crop out bits and pieces from an image, allowing the model to learn from non-perfect data, which is a better fit for real-world situations.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2X-mL0KmR97BYoQP" /></figure><p>We can use all the methods mentioned above to increase the size of our dataset manifold. Augmentation can save hours of manual data annotation; however, with so many techniques available, it can also be a cumbersome task.</p><p>Luckily, Picsellia’s automated <a href="https://www.picsellia.com/automated-pipelines">CVOps pipeline</a> gives you complete control over your dataset. You can choose from several different augmentation techniques and construct a custom pipeline. Picsellia’s smart feedback loop allows you to retrain your model with modified data and different parameter configurations. Its model monitoring system keeps <a href="https://www.picsellia.com/experiment-tracking">track of which models and parameters perform best</a>.</p><h3>Takeaways</h3><p>Data scarcity can be a nightmare for computer vision engineers because data collection is frustrating. It requires several hours of work to collect and manually annotate images.</p><p>Image data augmentation techniques are used to synthesize more data from the existing example image set to tackle this problem. These techniques help generate image data, providing CV models with new information that can help them understand the data better and improve its performance.</p><p>Picsellia offers an <a href="https://www.picsellia.com/post/creating-a-cvops-platform">automated CVOps pipeline</a> built with advanced computer vision techniques. Our <a href="https://www.picsellia.com/dataset-management">integrated image labeling tools and built-in data augmentation</a> module allows hassle-free management of data. To know more about our platform, <a href="https://www.picsellia.com/contact">book your demo</a> today!</p><blockquote>Originally posted by <a href="https://medium.com/u/d7fe9a1b08b5">Haziqa</a> for www.picsellia.com</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bb99e4f54a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/what-is-image-data-augmentation-and-why-use-it-8bb99e4f54a1">What Is Image Data Augmentation and Why Use It?</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Do Classical MLOps Tools Not Fit Computer Vision?]]></title>
            <link>https://medium.com/picsellia/why-do-classical-mlops-tools-not-fit-computer-vision-39f40b9c8372?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/39f40b9c8372</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Wed, 06 Jul 2022 14:21:51 GMT</pubDate>
            <atom:updated>2022-07-06T14:21:51.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mpkPxn4bwJgCIo8CS2yfzg.jpeg" /><figcaption>Source: freepik — pch.vector</figcaption></figure><p>Computer vision (CV) is one of the most mature domains in artificial intelligence (AI). However, building and operationalizing robust, end-to-end computer vision pipelines is challenging in the modern AI ecosystem.</p><p>Why? Because production-deployed computer vision models show arbitrary behavior due to several factors related to data, model design, architecture, and deployment.</p><p>In the ML ecosystem, MLOps (Machine Learning Operations) is a set of practices to track and monitor the performance of the entire ML pipeline using processes such as CI/CD (Continuous Integration/Continuous Delivery) and CT (Continuous Training).</p><p>Mainly, MLOps automates data validation, model validation, and model retraining cycle in a production environment. Moreover, it offers a monitoring mechanism that alerts the development team if the model’s performance deteriorates.</p><p>However, in the computer vision ecosystem, regular MLOps practices are not optimal due to the following reasons:</p><ul><li>Data is unstructured, and data manipulation is done differently.</li><li>Edge cases or under-represented classes can impact the model’s performance more.</li><li>CV is more data and hardware intensive than other ML domains.</li></ul><p>Computer vision pipelines require a set of processes that are exclusive to Computer Vision. This is where CVOps–a fusion of MLOps and computer vision is more suited.</p><p>In this article, we’ll have a detailed discussion about why classical MLOps tools are unsuitable for computer vision tasks. We’ll also discuss how a <a href="https://www.picsellia.com/post/how-to-apply-mlops-to-computer-vision-cvops">CVOps pipeline</a> is better equipped to streamline your entire CV stack.</p><h3>How Is Data Manipulation Different in Computer Vision?</h3><p>Data comes in all shapes and sizes, including structured, unstructured, and semi-structured. However, most of the enterprise data is unstructured.</p><p>In fact, a report suggests that more than <a href="https://mitsloan.mit.edu/ideas-made-to-matter/tapping-power-unstructured-data">80%</a> of data is unstructured, which includes images, videos, emails, web server logs, and more. But only 18% of organizations leverage this data–a <a href="https://www2.deloitte.com/us/en/insights/topics/analytics/insight-driven-organization.html">Deloitte report</a> suggests.</p><p>In computer vision, the majority of data is unstructured in the form of images and videos. Hence, exploring and visualizing data is difficult compared to structured data. Imagine browsing through one million unstructured images compared to one million rows of structured textual data stored in a .csv file or relational database. Moreover, images and videos require more storage capacity and processing power than structured data.</p><p>Furthermore, collecting and preparing labeled image and video datasets often require time-intensive manual intervention. Often there is not enough visual data to support CV model training. Other times the data requires hand annotation, which is labor-intensive and costly.</p><p>Similarly, filtering images and videos is a challenge. Just imagine creating a dataset of seasonal flowers from a large collection of plant and flower images without any labels or tags. Enterprises employ metadata management tools to tag and categorize images to make them searchable and accessible. This, again, requires pricey human intervention.</p><p>Rather than an MLOps tool, a robust CVOps tool solves all these problems by providing a centralized and integrated solution that covers data collection, storage, manipulation, filtering, and more.</p><h3>Model Validation Needs to Be Focused on Edge Case Visualization</h3><p>Model validation determines if the model is generalized enough to cater to all input scenarios. However, in the real-world, unlikely situations often occur. For instance, an autonomous car is trained for regular road scenarios. How would the vehicle respond if there was an unexpected event? Like a high-speed car chase by five police cars, sudden rain, and thunderstorm that changes the driving conditions. Or what if a person comes in front of the car by accident? These are known as edge cases which are unlikely and unusual but have a non-zero probability of occurring.</p><p>Besides the unpredictability of input scenarios, edge cases occur due to bias and variance in the model. The model is either too simple or too inexperienced to handle the incoming real-world data.</p><p>In computer vision, edge cases have a significant impact on the performance of the model. Edge cases in computer vision are more subtle as they’re often related to ambiguous visual aspects. Human annotators can sometimes fail to identify edge cases resulting in mislabeling. In images, edge cases can also occur if two objects are entirely different in their nature and properties but look visually similar. Take a look at the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/0*apkekxWCcVUFIYeP.png" /><figcaption><em>Source: </em><a href="https://medium.com/@livewithai/the-significance-of-edge-cases-and-the-cost-of-imperfection-as-it-pertains-to-ai-adoption-dc1cebeef72c"><em>Live With AI</em></a></figcaption></figure><p>The only similarity between a dog and fried chicken is that humans love them–one as a pet and the other as food. These kinds of visually similar images jeopardize the performance of computer vision models. In mission-critical applications, such similarities can prove fatal. Even one in ten misspredictions could result in loss of revenue or mission failure.</p><p>Complex CV tasks require tools to visualize image data to effectively identify edge cases in order to avoid any real damage. A robust CVOps platform can provide the necessary tools to handle such edge cases.</p><h3>Monitoring Needs to Be Focused on Data and Hardware</h3><p>Computer vision tasks are data and hardware-intensive. Classical MLOps strategy does not offer detailed monitoring of production-deployed CV models because it is not equipped to monitor them.</p><p>In particular, computer vision monitoring includes tracking hardware devices like CCTV cameras, medical scanning and imaging instruments, and other edge devices. Each device can have specific configurations that might affect the performance of the CV model. For instance, the orientation of cameras installed on a roadside for traffic analytics might change due to wind or other environmental factors, causing the model to capture inaccurate input images for which the model was not trained.</p><p>To monitor such changes, you might require out-of-the-box or vision-specific metrics that differ from classical ML performance metrics. Some of these <a href="https://www.picsellia.com/post/whamonitor-when-building-a-computer-vision-monitoring-solution">CV monitoring metrics</a> include:</p><ul><li>Input image width and height</li><li>Image ratio distribution</li><li>Inference time</li><li>AE outlier score</li><li>KS drift</li></ul><p>Besides these, the development team should be able to monitor various distribution drifts such as data drift, concept drift, domain drift, prediction drift, and upstream drift. A robust CVOps model offers monitoring capabilities that are often missing in regular MLOps tools.</p><p>We have discussed various reasons why regular MLOps pipelines are not suitable for computer vision applications. And lastly, we introduced CVOps as an appropriate solution. Now, let’s demystify CVOps in detail.</p><h3>In Comes CVOps–Specialized MLOps for Computer Vision</h3><p>If you are wondering, what is CVOps, exactly? Simply put, it is a combination of MLOps and computer vision, similar to how MLOps is a combination of DevOps practices tailored for machine learning tasks.</p><p>CVOps curates enterprise best practices, business processes, and tools and employs CV-specialized experts for building production-ready computer vision products. The product environment usually includes a camera or edge device installed in a real-world setting–for instance, cameras installed on the roadside for road safety and traffic monitoring systems.</p><p>In addition, CVOps tools specialize in tracking the behavior of data and models over time. They can track metrics and KPIs to identify distribution drift and device calibration issues. A CVOps tool can notify your development team if the threshold values of these metrics are reached, enabling them to deliver timely data and model updates.</p><p>Moreover, a robust CVOps strategy includes factors such as data and model scalability and the costs associated with it. It includes managing multiple edge devices and implementing solutions for each device simultaneously.</p><p>An enterprise CVOps strategy is also concerned with tracking and maintaining customer satisfaction over time. If the model performance deteriorates, the CVOps strategy should provide quick resolution of any related issues to ensure customer success.</p><h3>Build Robust CVOps Pipelines With Picsellia</h3><p>General MLOps tools are suitable for most machine learning and deep learning tasks. However, CVOps tools are more capable of solving the unique challenges of vision-powered systems. They can manage, manipulate, analyze, annotate, and validate image and video data. They can train, validate, retrain, monitor, and release CV pipelines in a production environment.</p><p>Depending on business requirements, CV teams can use packaged enterprise CVOps tools or build their custom CVOps strategy. If you opt for a pre-built platform, look no further than Picsellia.</p><p><a href="https://www.picsellia.com/">Picsellia</a> is a robust <a href="https://www.picsellia.com/post/creating-a-cvops-platform">end-to-end CVOps</a> platform that offers the following features to assist data scientists and enterprise vision teams:</p><ul><li>Centralized dataset management for unstructured data like images and videos</li><li>Integrated image labeling and model training tools</li><li>Experiment tracking fine-tuning and obtaining the best performing model</li><li>Production-ready serverless model deployment</li><li>Real-time CV model monitoring with edge case identification</li><li>ML automated workflows covering each component of the CV pipeline.</li></ul><p>Moreover, Picsellia offers <a href="https://www.picsellia.com/post/whamonitor-when-building-a-computer-vision-monitoring-solution">supervised and unsupervised metrics</a> to identify any drift and monitor overall CV workflows.</p><p>Start using Picsellia’s CVOps platform for free. <a href="https://bit.ly/3shSsNh">Book your trial</a> today!</p><p>Originally posted on <a href="https://bit.ly/3ALJnBp">Picsellia’s Blog</a> by <a href="https://medium.com/u/d7fe9a1b08b5">Haziqa</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39f40b9c8372" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/why-do-classical-mlops-tools-not-fit-computer-vision-39f40b9c8372">Why Do Classical MLOps Tools Not Fit Computer Vision?</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Optimize Computer Vision Models For Edge Devices]]></title>
            <link>https://medium.com/picsellia/how-to-optimize-computer-vision-models-for-edge-devices-851b20f7cf03?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/851b20f7cf03</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[edge-computing]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Tue, 05 Jul 2022 13:53:32 GMT</pubDate>
            <atom:updated>2022-07-05T13:53:32.972Z</atom:updated>
            <content:encoded><![CDATA[<p>This article will introduce you to <strong><em>“Inference at the Edge”</em></strong> and <strong><em>“Inference Optimization Techniques”</em></strong> in Machine Learning. By the end of this article, you will know about the most relevant optimization techniques for decreasing model size and increasing its inference speed in computer vision. You will also learn about the open-source tools<em> </em>you can use to achieve these optimizations. Last but not least, we will advise you on the deployment optimization techniques you should use in your computer vision projects, depending on your<em> </em>deployment hardware<em>.</em></p><h3>What is Inference at the Edge and When Do You Need It?</h3><p>You may have heard the phrases “AI at the Edge”, “Edge ML” or “Inference at the edge”. These terms refer to trained machine learning models running inference tasks near the production data collection point, usually in real-time. The inference is executed on edge devices (e.g.microcomputers, accelerators, mobiles, IoT). A typical example is self-driving cars. They gather information about the surrounding area through multiple sensors and process it in local hardware in real-time. Real-time refers to the maximum prediction delay we can afford and range from a few milliseconds up to a couple of seconds depending on the application.</p><p>Inference at the Edge offers many benefits and is sometimes the only viable way to design your computer vision system. In short, Inference at the Edge offers:</p><ul><li>Remote inference capabilities (production data lies on the field, away from a server)</li><li>Real-time predictions</li><li>Independence from network connection</li><li>Data storage reduction (you only keep predictions and discard the production data)</li><li>Data security, as there is limited need to transfer (sensitive) data through a network</li></ul><p>However, it is subject to a lot of constraints like the limited processing power of the hardware, memory limitations, limited battery life unless connected to a power plug, possibly higher costs, and a slightly more complex model deployment phase. Hence, you should carefully decide if inference at the edge is necessary for your project. In short, if none of the above bullet points is a strict requirement, you can probably get away with transferring the collected data to a cloud server for inference and back if necessary.</p><p>If you have decided that Inference at the Edge is the best design for your application, you will need to respect the processing constraints. When you run inference in local low-power hardware you don’t have the luxury to process data with very large deep learning models, as the latency might exceed real-time constraints. Fortunately, there are optimization techniques to help reduce the size of a network and its inference delay.</p><h3>Speed and Memory Optimization Techniques</h3><p>Edge devices often have limited memory or computational power. You can apply various optimizations to your models to run them within these constraints. Model optimization is especially useful for:</p><ul><li>Reducing inference latency for both cloud and edge devices.</li><li>Deploying models on edge devices with restrictions on processing, memory, and/or power consumption.</li><li>Enabling execution on hardware restricted-to or optimized-for fixed-point operations (integer numbers).</li><li>Optimizing models for special purpose hardware accelerators.</li><li>Reducing model storage costs and model update pay-loads (for over-the-air updates).</li></ul><p>We will go through some of the most crucial techniques of size and speed optimization.</p><h3>1. Choose the Best Model for the Application</h3><p>The following step is not an optimization technique, but it’s the most relevant stage to start with. Before you train your model take into account the precision and inference speed you need to achieve. You need make a tradeoff between model complexity and size. Smaller models are often good enough for most tasks, require less disk space and memory, and are much faster and energy efficient. The graphs below help understand this tradeoff better. Looking at the accuracy vs. latency chart, you need to decide whether a Mobilenet v2 has enough accuracy for your needs or if you need to move to a more complex model like the NASNet mobile or Inception v3 (quantized). In any case, Inception v4 is probably not an option for real-time inference.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*aYK7-9KeKDmRB6Ps.png" /><figcaption>Model Size- Accuracy — Latency Tradeoff Source — <a href="http://www.tensorflow.org/lite">www.tensorflow.org/lite</a></figcaption></figure><h3>2. Post-Training Weight Quantization</h3><p>Quantization is the technique of constraining a large set of (continuous) values to a smaller set of (discrete) values. In neural networks, post-training quantization is a technique that reduces the number of necessary bits to represent a network’s weights, biases, and activation functions [1]. Post-training quantization involves taking a trained model, quantizing its weights, and then optionally re-optimizing the model.</p><p>The standard process is to represent a network’s parameter as 32-bit floating-point values, which allows for high numerical precision and, ultimately, accuracy for the neural network. By converting 32-bit floating-point representations to reduced precision numerical types, we can effectively reduce a parameter’s size by 2x to 4x, depending on the quantization type. This would translate to a model with an initial size of 128 MB reduced to approximately 64MB or even 32MB!</p><p>The most common quantization techniques convert the numerical type to 16-bit floating-point (half-quantization) or 8-bit integer (full-quantization) numbers. Quantization to 8-bit integers has two options, <em>Full Integer Quantization</em>, and <em>Dynamic Range Quantization</em>. The former will quantize weights, biases, activations, inputs and outputs (given a representative dataset), while the latter only quantizes weights. Depending on your hardware, some techniques work better than others, but we will dive deep into this in the next section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eEDzNwBK9P7hET_u.png" /></figure><p>However, in computer science a free launch rarely exists. By reducing the numerical precision, you can degrade your model’s overall accuracy. Depending on the severity of quantization, we usually perceive an accuracy drop of approximately 0–2%. Though for a 2% accuracy drop we may achieve up to 84% energy saving [2] and 3x or more speedup. In most cases, accuracy degradation lies below 1%, while in some rare cases we might even experience a slight accuracy increase, usually an overfitted and complex model regularized as a result of quantization.</p><h3>3. Model Pruning</h3><p>Pruning removes redundant parameters or entire neurons that do not significantly contribute to the accuracy of the results. This condition may arise when the weight coefficients are zero, close to zero, or replicated. As a result, you can reduce computational complexity while maintaining inference speed increases and accuracy at stable levels. Pruned networks can also be retrained afterward, providing a possibility of escaping previous local minima and further improving accuracy [3].</p><h3>4. Weight Clustering</h3><p>Clustering, or weight sharing, reduces the number of unique weight values in a model, leading to benefits for deployment. It first groups the weights of each layer into <em>N</em> clusters, then shares the cluster’s centroid value for all the weights belonging to this cluster. You can cluster layers selectively. The smaller the number of clusters, the bigger the level of compression, and vice-versa.</p><p>In table 1, we see that almost 3.5x compression can be achieved with a minimal 1.6% loss of accuracy when clustering all Convolutional layers with 32 clusters. A 2x compression can be achieved by clustering just 3 Conv layers with an accuracy reduction below 0.3%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/0*QRR-SnCzgYYRFmUV.png" /><figcaption>Table 1. Effects of weight clustering on models trained for image classification on ImageNet. Source [4] <a href="https://www.tensorflow.org/model_optimization/guide/clustering">https://www.tensorflow.org/model_optimization/guide/clustering</a></figcaption></figure><h3>Open Source Tools for Inference Optimization</h3><p>We discussed the techniques, so now we will discuss tools that apply them. In table 2, you can see a comprehensive but not exhaustive list of open source tools for neural network inference optimization.</p><p>Among them,<a href="https://www.tensorflow.org/lite"> TensorFlow Lite</a> is probably the most well-rounded and flexible. It offers many different quantization techniques, pruning, weight clustering, and an experimental feature for Quantization Aware Training. It supports a wide range of hardware devices during inference and is easy to use. However, it only supports TensorFlow models directly. But you can optimize models written in other frameworks by leveraging a global neural network format called<a href="https://onnx.ai/"> ONNX</a>.</p><p>Another important SDK, tied to NVidia GPUs, is the<a href="https://developer.nvidia.com/tensorrt"> TensorRT</a> library. It is a library created by NVidia specifically for their hardware. It offers system-specific optimizations that result in very-high performance inference. Moreover, it supports both TensorFlow and PyTorch models. If very low latency and high throughput is the goal, TensorRT is the optimal tool to work with. However, it is limited to NVidia hardware and it can be a little frustrating to work with it on their embedded devices (<a href="https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/">jetson series</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nl1q1L6sGY4MRjCY.png" /><figcaption>Table 2. Source: [1]<a href="https://arxiv.org/pdf/2101.09671.pdf"> https://arxiv.org/pdf/2101.09671.pdf</a></figcaption></figure><h3>How to Find the Right Optimization Technique for Your Hardware</h3><p>Now that we have explained the key optimization techniques and tools, we will dive into the details of picking the most suitable optimization for your hardware. Sometimes, choices are limited because of hardware architecture, but sometimes you can get to choose.</p><p><strong>Deploying on low-power CPUs</strong>: This could be a microcomputer’s (e.g. Raspberry Pi) CPU, a mobile phone’s CPU, or even a commercial laptop CPU. Float-16 bit quantization is possible, but in this scenario you should prefer quantization to int-8 bits. The reasons are:</p><ol><li>CPUs are very fast when working with integers</li><li>By default, a float16 quantized model will “dequantize” the values of the weights to float32 when run on the CPU<a href="https://www.tensorflow.org/lite/performance/post_training_quantization#float16_quantization"> [4]</a>.</li></ol><p>With TF-Lite you can opt for a dynamic range, or a full integer quantization. You can effectively reduce a model’s size 4x and get 2–3x speedup, usually with a low accuracy loss. But, make sure to verify that the optimized model’s accuracy still lies inside the desired range.</p><p><strong>Deploying on an android GPU: </strong>For android GPUs, TF-Lite supports the same quantization techniques as listed above. We suggest following the same guidelines.</p><p><strong>Deploying on integer-only hardware: </strong>Many microcontrollers and many edge TPUs only support integer operations. If your hardware falls under this category, then your only option is to use<a href="https://www.tensorflow.org/lite/performance/post_training_quantization#full_integer_quantization"> full integer</a> quantization. The speedup will be huge, especially for TPUs, but make sure you evaluate the quantized model to verify that accuracy still lies inside the desired range.</p><p>‍<strong>Deploying on NVidia GPUs: </strong>This category includes commercial high-end computing GPUs and embedded GPUs like the NVidia Jetson series. In this scenario, you have the option to work with Tensor RT. TensorRT will handle the optimizing details and can help you achieve real-time FPS (20–60 fps).</p><p>A GPU’s architecture is optimized for operations with floating point numbers. Quantization down to 16-bit floating-point numbers is usually a great starting point. If the 2x size reduction is still not enough to achieve the optimal inference speed, then a conservative pruning or weight clustering may also be applied. TF-Lite only supports quantization to 16-bit float for these GPUs. However, TensorRT also provides full quantization to 8-bits.</p><h3>Can I Use Optimized Models in the Cloud to Achieve Real-Time?</h3><p><strong>Deploying on the cloud: </strong>When deploying your solution on the cloud, you have access to powerful hardware, which lets you opt for a bigger and more complex model to start with. However, you may still find it necessary to decrease the delay from input to prediction, to achieve real-time.</p><p>In this case, your biggest enemy is the network’s speed and bandwidth. Since you need to transfer data back and forth, a big part of the overall delay is data transfer costs. If your data transfer delay exceeds the application’s real-time constraints, then you shouldn’t bother optimizing inference speed in the first place. Instead, go for an edge device.</p><p>On the other hand, if data transfer delays are not a bottleneck, we advise to optimize your model for inference speed. Assuming that inference is executed on a high-end GPU, then a lightweight compression to 16-bit floats, weight clustering of specific hidden layers, or a combination of some sort should provide you with enough speedup to meet your real-time restrictions without sacrificing a lot of accuracy.</p><h3>References</h3><p>[1]<a href="https://arxiv.org/pdf/2101.09671.pdf"> Pruning and Quantization for Deep Neural Network Acceleration: A Survey</a>.Tailin Liang, John Glossner, Lei Wang, Shaobo Shi, and Xiaotong Zhang</p><p>[2]<a href="https://arxiv.org/pdf/1612.03940.pdf"> Understanding the Impact of Precision Quantization on the Accuracy and Energy of Neural Networks.</a> Soheil Hashemi, Nicholas Anthony, Hokchhay Tann, R. Iris Bahar, Sherief Reda</p><p>[3]<a href="https://arxiv.org/pdf/2003.03033.pdf"> What is the state of Neural Network pruning?</a>. Davis Blalock, Jose Javier Gonzalez Ortiz, Jonathan Frankle, John Guttag</p><p>[4]<a href="https://www.tensorflow.org/lite/performance/model_optimization"> https://www.tensorflow.org/lite/performance/model_optimization</a></p><p>[5]<a href="https://developer.nvidia.com/tensorrt"> https://developer.nvidia.com/tensorrt</a></p><p>Originally posted on <a href="https://bit.ly/3adWekH">Picsellia’s Blog</a> by <a href="https://medium.com/u/18fd5e3887bd">Poulinakis Kon</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=851b20f7cf03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/how-to-optimize-computer-vision-models-for-edge-devices-851b20f7cf03">How To Optimize Computer Vision Models For Edge Devices</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Versioning & Feedback Loop Best Practices in Computer Vision]]></title>
            <link>https://medium.com/picsellia/dataset-lifecycle-the-importance-of-feedback-loops-and-versioning-in-computer-vision-89f334f38c85?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/89f334f38c85</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 08:40:16 GMT</pubDate>
            <atom:updated>2022-06-06T12:38:36.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Author: <a href="https://www.linkedin.com/in/konstantinos-poulinakis-4554821a3">Konstantinos Poulinakis</a> for Picsellia</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*8faviZdpVp-PqZqjg-RMVQ.png" /></figure><h3>Content</h3><ul><li>What are good practices for dataset versioning?</li><li>Defining a dataset governance policy.</li><li>The feedback loop deployment scenario. Its pros and cons.</li></ul><h3>The Importance of Data Versioning</h3><p>Software code versioning has long been a standard practice in the IT industry, using tools like git. Environment versioning is also gaining a lot of traction, using tools like Docker. However, data versioning is still not as prevalent in the Machine Learning industry even though its adoption offers valuable benefits. Then you may wonder, why is versioning so important?</p><p>Just like with software code, versioning datasets at different times lets you roll back to previous versions easily. This is vital for experiment reproducibility, as any change in the data will stir a model’s results in different directions. Moreover, it offers an adequate solution to documenting data lineage and origin, <strong>especially crucial when feedback loops are incorporated into a system</strong>. Versioning is also an indirect way of backing up data,<strong> </strong>although it should not replace formal backups.</p><p>Furthermore, data versioning is an effective methodology you should follow when running many experiments that entail different data processing techniques. Each experiment should be versioned, offering easy access to a specific stage and avoiding unintended changes. Finally, versioning’s importance shines when big engineering teams are working on the same data. We will further elaborate on data governance later on.</p><p>But first, let’s introduce some data versioning best practices you must consider in your computer vision projects.</p><h3>5 Best Practices For Data Versioning in Computer Vision</h3><ol><li>Version on the pipeline’s key stages. Data versions are most meaningful when used during the start and/or completion of data pipeline tasks. An ETL script finished running? Create a version. Did you run a corruption-detection script and deleted corrupted images? Create a version. Ideally, you want a version after every pipeline task, from raw data up to the final version.</li><li>Version’s names should reflect the data status and position in the pipeline. A version’s name should be descriptive. You shouldn’t need to roll back to a version to check the dataset’s stage. Some examples of self-descriptive version names could be “defects_dataset-cleaned-normalized-feedback_loop”, “non_defects_dataset-raw”. However, a standard <a href="https://devopedia.org/semantic-versioning">three-part semantic version number convention</a> can be used to effectively encode a pipeline’s stages. In either case, the name should convey relevant information.</li><li>Create metadata for each version. This could even be a simple .txt file documenting important information about the dataset up to that point. You should include information that can’t fit in the title but is important to document. A metadata file should state which data, in particular, was affected by the changes, the number of new and total images included in the dataset, the origin of the new data, the processing that has been performed in detail, and any other valuable fact decided by your Data team. This necessity is reinforced when feedback loops are introduced, but more on that later.</li><li>Automate the versioning. In most cases, data versioning is a repetitive and dull task. Such tasks cut away time from data scientists who ought to spend their time creating and deploying valuable models. Aim to automatically version a dataset after every key pipeline stage. Picsellia’s unique <a href="https://www.picsellia.com/dataset-management">data management platform</a> can save valuable time and take the burden off your shoulders. Check for yourself <a href="https://documentation.picsellia.com/docs/create-a-new-dataset-version">how you can use code and no-code solutions to quickly version datasets</a> without any hustle, by using Picsellia.</li><li>Leverage versioning for intra-team cooperation. When multiple people are working on the same version of a dataset, there is always a possibility of inadvertently making changes that affect others’ work. Usually, each collaborator should work on his/her version during experiments, while also maintaining a main (“master”) version, which everyone can read, but not write on. This is a data governance policy that team leaders should implement.</li></ol><h3>The Importance of Data Governance</h3><p>With predictive analytics and Machine Learning’s huge adoption, data is fuel for growth. Data influx is increasing month by month in most companies. Data is a resource and should be managed accordingly. However, when working across large engineering teams, efficient data management becomes a complex, nonetheless crucial, operation. It is integral to set up a Data Governance System in place. By data governance, we mean a set of rules, policies, and standards to be followed.</p><p>Some important policies and standards you should define are:</p><ol><li>How data is collected.</li><li>What metadata needs to be documented.</li><li>What data quality is acceptable, and what happens to data that don’t meet the criteria. E.g. blurred, corrupted, and/or high contrast images should be deleted and not moved down the pipeline.</li><li>Set up naming conventions for files, datasets, and versions.</li><li>When datasets should be versioned. Will different team members work on their versions? Who is allowed to write on the main version?</li><li>What type of data storage architecture best fits your organization’s needs. Should you store it in a data lake or a data warehouse? Is it worth creating a feature store?</li></ol><p>Defining, setting up, and abiding by these rules and guidelines helps put order into the increasing amount of data influx and avoid the chaos that comes along with it. Most of the time, using an MLOps platform to help with data management, <a href="https://www.picsellia.com/post/mlops-platform-build-vs-buy-what-you-must-know">is worth the investment</a> as data scientists and ML engineers can focus their energy on how to deliver value with their models.</p><p>This need becomes more prevalent as we move away from traditional data lifecycles to modern ones like feedback loops.</p><h3>The Feedback Loop Deployment Scenario</h3><p>Machine Learning model deployment is an ongoing<strong> process</strong> rather than a task. It is dynamic as it entails constant <a href="https://www.picsellia.com/model-monitoring">monitoring</a> of a model’s performance. Models in production have expiration dates. Data and concept drift quickly degrade a model’s performance, ultimately hurting business metrics and profits. But even without drifts, once deployed, a model’s performance might simply not meet the expectations set during the evaluation stage. This is where feedback loops and online learning become vital. They allow for quick model updates, adjusted to new data distributions and environmental variables.</p><p>Think of a defect-detection model in an industrial setting; a visual detection system for broken or scratched mobile screens. After gathering data, training, and deploying a model, shifts take place in the industrial setting, out of the machine learning engineers’ control. Light intensity is altered, and the background conveyor belt’s color changes. Even these small environmental changes can produce unintended underperformance of the visual system. Hence, retraining becomes necessary.</p><p>In this example, assuming that the model is not completely useless anymore and starting the training process from ground zero, is not cost-effective and demands plenty of time. You need a system able to dynamically retrain a model online, using <strong>fewer but relevant</strong> data. Retraining can be triggered by performance thresholds, data drift detection, or fixed time intervals. When the model produces an incorrect output, it should be captured, documented, and included in an <strong>updated version</strong> of the dataset. Picsellia’s <a href="https://www.picsellia.com/model-monitoring?utm_source=Article&amp;utm_medium=Medium&amp;utm_campaign=Monitoring&amp;utm_term=Data+Drift">monitoring</a> features offer these capabilities. Detection of wrong predictions always requires a human to enter the loop. Consequently, a combination of old and newly acquired data is used to retrain the model. This updated dataset provides a better representation of the “new” reality.</p><h3>Feedback Loops Pros</h3><p>With feedback loops set in place:</p><ul><li>Models don’t become outdated and performance is maintained at high levels throughout the deployment phase. Depending on a model’s use case, this translates into superior quality services or higher profits.</li><li>You’ll decrease model downtime. Less time redesigning, retraining, and evaluating a model correlates to more time serving.</li><li>Computational resources are saved. Since retraining is typically conducted with fewer epochs and data, you’ll reduce computational needs. This is crucial when you’re using cloud solutions and are billed on usage.</li></ul><h3>Feedback Loops Cons</h3><p>However, feedback loops have hidden drawbacks. First, since the dataset versions created during a feedback loop are mainly sampled from a model’s mistakes, the version might be inherently coupled to the model used while generating it. Thus, it may not transfer well to another model. Second, the engineering team may get trapped in a never-ending loop of retraining, to revive a “dead” model. Sometimes, concept and data drifts are so wide that the only viable option is to start the training from ground zero again.</p><p>Moreover, feedback loops add complexity to a system’s architecture. The typical train-evaluate-deploy architecture can’t handle feedback loops efficiently. You need an architecture that incorporates performance, concept, and data drift monitoring. Such systems are harder to design and maintain. Hopefully, <a href="https://www.picsellia.com/">Picsellia’s CVOps platform</a> offers these services through an easy-to-use and collaborative interface, helping you preserve relevant resources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89f334f38c85" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/dataset-lifecycle-the-importance-of-feedback-loops-and-versioning-in-computer-vision-89f334f38c85">Data Versioning &amp; Feedback Loop Best Practices in Computer Vision</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Built a Dataset Visual Similarity Search Feature By Using Embeddings and Qdrant]]></title>
            <link>https://medium.com/picsellia/how-we-built-a-dataset-visual-similarity-search-feature-by-using-embeddings-and-qdrant-ec9787383058?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec9787383058</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Wed, 18 May 2022 14:20:30 GMT</pubDate>
            <atom:updated>2022-05-18T14:20:30.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tivABpc_yNpZ4cBrlD6xtA.png" /><figcaption>Image Source: TiefVision at GitHub</figcaption></figure><p>As we examined in our last <a href="https://www.picsellia.com/post/data-management-in-ai-key-success-factor">article</a><strong> </strong>some of the key features of an efficient Data Management system are data exploration and filtering. We have defended this for a long time now, but we never had the time to add this feature to our platform. These times are gone!</p><p>In this article, we’ll walk you through the general concept of image embedding, and how we implemented our scalable visual search feature to find similar images across millions of images for multiple clients at the same time.</p><h3>What’s an Embedding?</h3><p>Embeddings are a way of mapping discrete variables to continuous numbers. In the context of neural networks, embeddings are low-dimensional vector representations of categorical variables.</p><p>Neural network embeddings allow for close neighbors in the space and can be used to make recommendations based on user interests, cluster categories, or input into machine learning models for supervised tasks that need vectors as input, like classification tasks that use labels learned from labeled data (such as spam detection).</p><p>Embedding visualization is useful as it lets people see concepts and relations between different categories within a given dataset, more clearly than traditional methods do, by reducing dimensionality without losing information about what is being represented.</p><p>Here, our goal is to leverage embeddings to quickly identify similarities in images (without a-priori info on the similarity features).‍</p><h3>How to Generate Image Embeddings?</h3><p><strong>Transformation Based Descriptors</strong>‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1wA-3XOROs8giKMp.png" /></figure><p>‍You have multiple strategies to generate your image embeddings. The whole point is to select a set of features that will represent your images in the best way possible. To do so, you can use some classical descriptors like SIFT (Scale-Invariant Feature Transform) or SURF (Speeded Up Robust Features). These approaches focus on point of interest identification and matching, which is a great way to find similar objects in an image that are in different positions.</p><p><a href="https://medium.com/data-breach/introduction-to-surf-speeded-up-robust-features-c7396d6e7c4e">Here</a> is a good introduction to SURF!</p><p>To generate them, you can use OpenCV. <a href="https://docs.opencv.org/3.4/df/dd2/tutorial_py_surf_intro.html">Here</a> is a link to an OpenCV tutorial on SURF computation.</p><p>Please note that SURF and SIFT algorithms are patented and can’t be used commercially, a great alternative can be ORB (Oriented FAST and Rotated BRIEF).</p><h3>Convolution Nets Based Descriptors</h3><p>As we saw, classical descriptors are great to identify any kind of transformation and match two images that look a lot like. But, if you want to create a more symbolic search for similarity, you’ll need another method.</p><p>That’s why convolutional neural networks are so powerful. In the past ten years, deep learning models have achieved very high accuracy levels to classify pictures. These deep learning ConvNets can be used to extract features from pictures that are invariant; not only when it comes to geometric transformation, but also in the instance itself! What does this mean? Two images of the same category will have the same representation.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*bK98tYEUKYg8zh9F.png" /></figure><p>‍The goal is to use the vector of features generated by the ConvNet features extractor, to build a vector space corresponding to all the images of your set.</p><p>There are so many ConvNet models out there that it has become a complex task to decide which one to use. When building a scalable visual search feature, you will need to generate various embeddings over time for your entire data lake. Thus, it’s a good idea to find a great trade-off between the size of the model, inference time and accuracy.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A8QhpjZaheZgVGgu.png" /><figcaption>AI Google Blog</figcaption></figure><p>‍The latest EfficientNet architectures released by the Google team are a great choice since the number of parameters (thus, the size and inference time) of the model is significantly lower than the ones of ResNet, for example. So an EfficientNet-b0 can be a good fit for our use case. To generate the embeddings, we are using the <a href="https://github.com/christiansafka/img2vec">img2vec Python package</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vSxYLM05ghjxhnzs.png" /></figure><p>‍Now that we have everything we need to generate our embeddings, we can think about the similarity search strategy.</p><h3>How to Implement Visual Search?</h3><p>Once we have embeddings for all our images, we need to create an index for each data. Here, as we are building a feature to interact with the pictures stored in Picsellia’s data lake, we are going to use our data’s UUID as an index.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*COu-VZtyjl__qCsJ.png" /></figure><p>Next, we want to find, given an index, the N most similar pictures.</p><h3>Brute Force Search (Euclidian, Cosine, etc.)</h3><p>A simple way to implement a similarity search is to compute the distance of a given feature vector between all the other vectors and then select the N closest neighbors. For this approach, you only need to consider the distance that you want to compute, vector similarity is often computed through cosine distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wjiFmgsoCPVcBPXU.png" /></figure><p>‍The pseudo-code associated with this search would be:‍</p><p><strong><em>x = target_vector‍</em></strong></p><p><strong><em>for all indexes:</em></strong></p><p><strong><em>compute cosine_distance between x and the index</em></strong></p><p><strong><em>‍extract the K nearest neighbors</em></strong></p><p>‍This approach is considered brute force since the complexity of the search is linear (as shown in the graph below). For us, it’s completely impossible to use such approaches as we manage millions of images for multiple clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*92y0ap4WRxciVkNH.png" /></figure><h3>‍HNSW (Hierarchical Navigable Small World Graphs) — a Smarter Approach‍</h3><p>This algorithm has been introduced in the research paper “<em>Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs</em>” by <strong>Yu. A. Malkov, D. A. Yashunin.</strong></p><p>You can find the Python bindings to the C++ implementation <a href="https://github.com/nmslib/hnswlib">here.</a></p><p>The algorithm generates a graph where every node is a feature vector linked to its closest neighbor. When looking for the K nearest neighbor, you just have to navigate the graph and extract the K closest point.</p><p>The objective is to create an approximation of the search to reduce the number of computations performed and reduce the computational complexity of the search. In short terms, it allows us to search inside a 1m index’s database in milliseconds!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fc90QXxYBtZoiHWx.png" /></figure><p>‍</p><blockquote>Now let’s wrap it up by using Picsellia!</blockquote><h3>Behind the Scene of Picsellia’s Visual Search Implementation</h3><p>At Picsellia, we provide a Data Management platform to supercharge cloud object storage with indexing, filtering, search, visualization, and more. That’s why it makes sense for us to build some visual search features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*_qi3G89AQ2aWXj3M.gif" /><figcaption>Picsellia’s Data Lake</figcaption></figure><p>Pretty great speed right? Well, let’s see how we built this.</p><h3>Our Requirements</h3><p>To meet our development standards, our visual search feature needs to have these characteristics:</p><ul><li>Be standalone in a web microservice</li><li>Work on multiple siloed indexes collection for every client</li><li>Browse into millions of rows in milliseconds</li><li>Have a non-linear complexity</li></ul><p>These are essential needs, but if we want to develop everything in-house, we would have to put some effort into building a scalable solution meeting these requirements. Hopefully, as the neural search field is booming, there are many solutions on the market to address these requirements.‍</p><h3>Introducing Qdrant‍</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k9-fxreYH9gQyNK5.png" /><figcaption>Qdrant</figcaption></figure><p>“Qdrant (read: quadrant) is a vector similarity search engine. It provides a production-ready service with a convenient API to store, search, and manage points–vectors with an additional payload. Qdrant is tailored to extended filtering support. It makes it useful for all sorts of neural networks or semantic-based matching, faceted search, and other applications.</p><p>Qdrant is released under the open-source Apache License 2.0. Its source code is available on <a href="https://github.com/qdrant/qdrant">GitHub</a>.” <em>Source: </em><a href="https://qdrant.tech/documentation/"><em>Qdrant’s documentation</em></a><em>. </em>It implements a custom implementation of the HSNW algorithm allowing us to add extra filters to our query, and giving us complete modularity on our search, which is great for us!</p><p>Their open-source solution comes packaged in a single Docker image exposing a web server to communicate with. For our tech team, it’s perfect as we can wrap it up in a custom service that will generate the embeddings and easily store them inside the Qdrant collection.</p><p>In addition, they provide a set of APIs to register a new index and a corresponding id, to later retrieve the elements. We are using the unique id of the picture stored on our buckets, ensuring smooth communication between our services.</p><h3>Implementation</h3><p>The key phase is embeddings’ creation, and how to do it at scale without impacting the overall performance of the search engine and platform. To do so, we are using asynchronous tasks with Celery to queue all the work and keep the embeddings creation on CPU.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9VquQiXUVzRSbMD5.png" /></figure><h3>Wrapping up</h3><p>This new implementation allows us to generate embeddings for millions of images asynchronously without any impact on the overall performance of Picsellia’s products.</p><p>Once the embeddings are indexed and linked to our unique image ID, it gets really easy to find similar images in your dataset in no time! This makes dataset exploration as easy as ABC for you!</p><p>If you want to benefit from an entire Data Management suite packaged inside an end-to-end Computer Vision platform, just <a href="https://bit.ly/3lsg51r">claim your 14-day trial</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec9787383058" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/how-we-built-a-dataset-visual-similarity-search-feature-by-using-embeddings-and-qdrant-ec9787383058">How We Built a Dataset Visual Similarity Search Feature By Using Embeddings and Qdrant</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Key Metrics You Must Monitor When Building A Computer Vision Monitoring Solution]]></title>
            <link>https://medium.com/picsellia/key-metrics-you-must-monitor-when-building-a-computer-vision-monitoring-solution-72781871b515?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/72781871b515</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[ml-monitoring]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 13:01:59 GMT</pubDate>
            <atom:updated>2022-04-27T13:01:59.237Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Author: </em><a href="https://www.linkedin.com/in/haziqa-sajid-22b53245/"><em>Haziqa Sajid</em></a><em> for Picsellia</em></p><p>In computer vision (CV), high-quality training data does not ensure high-performing production models. The real work begins after production deployment when the model’s performance starts deteriorating due to multiple factors that we’ll discuss in this article.</p><p>Most importantly, disruption in the performance of a production-deployed computer vision model can lead to direct business loss. A robust computer vision monitoring solution aims to build a reliable system that can detect any underlying and previously unnoticed issues to prevent or mitigate production issues.</p><p>Computer vision monitoring is a crucial component of the <a href="https://www.picsellia.com/post/how-to-apply-mlops-to-computer-vision-cvops">CVOps pipeline</a> that can track key metrics, allowing computer vision vendors to make informed decisions. In this article, we’ll cover some of the key metrics to monitor when building computer vision monitoring solutions.</p><h3>What Could Break Your Computer Vision Model?</h3><p>CVOps teams can effectively monitor and maintain CV models in production. However, the model performance starts degrading right after deployment, just like other market products get devalued after manufacturing.</p><p>Computer vision models are dynamic and sensitive to changes in data distribution. The model goes out of context if any production data feature becomes unavailable or the real-world environment changes for which it was designed.</p><p>Monitoring the differences in the characteristics and behavior of a model with the latest data is critical to building robust CV pipelines. Therefore, tracking the CV models with several metrics and generating alerts or notifications helps maintain model relevance and reliability.</p><h3>Key Metrics To Monitor Computer Vision Solutions</h3><p>Metrics measure and record the performance of various business processes. The computer vision monitoring metrics can be split into unsupervised and supervised categories. Let’s discuss them below.</p><h3>Unsupervised Monitoring Metrics</h3><p>Unsupervised computer vision monitoring metrics don’t require user input for evaluating model performance. At Picsellia, we calculate various unsupervised computer vision monitoring metrics using our robust CVOps platform to help AI teams dissect CV models and identify performance degradation in real-time.</p><p>Following are some of these unsupervised metrics to monitor when building computer vision monitoring solutions:</p><ol><li>Input Image Width and Height</li><li>Image Ratio Distribution</li><li>Image Area Distribution</li><li>Inference Time</li><li>AE Outlier Score</li><li>KS Drift</li></ol><p>Let’s discuss them in detail.</p><p><strong>1. Input Image Width and Height</strong></p><p>Input images sent for making predictions can have variable orientations (width and height) over time. Such as, the users may add portrait pictures in the daytime and horizontal images at night.</p><p>Picsellia constructs a graph visualizing the widths and heights of pictures sent by the users. Analyzing the difference in image dimensions can reveal interesting facts about the behavior of users and data.</p><p><strong>2. Image Ratio Distribution</strong></p><p>Image ratio is the distribution of image width over height. Picsellia segregates the image ratios into six intervals. These six intervals are square, tall, very tall, wide, very wide, and extremely wide. Based on the value of the image ratio, the six intervals are thresholded at different values to segregate them on a histogram.</p><p><strong>3. Image Area Distribution</strong></p><p>Image area distribution is an important metric for defining the area covered by multiple input images, which helps in quick image validation. It is tracked using an area distribution histogram for multiple images.</p><p><strong>4. Inference Time</strong></p><p>The inference time of the model calculates the time taken to process novel data and make predictions. Inference time is calculated in the post-processing step of model development and gives an overview of the global latency of the CV model during inference.</p><p><strong>5. AE Outlier Score</strong></p><p>Outlier is the data value different from the rest of the data points. Models cannot make accurate predictions in the presence of outliers, making it necessary to track outliers, especially in production.</p><p>Picsellia uses an auto-encoder algorithm to determine outlier images from the production dataset by reconstructing images using a convolutional neural network (CNN) and assigns an outlier score to each image based on image reconstruction error. A higher value of the outlier score represents an outlier image.</p><p><strong>6. KS Drift</strong></p><p>Suppose at least one important data feature is no longer available to the same extent in the production dataset. In that case, the production set is considered to have drifted from the training dataset.</p><p>The Kolmogorov Smirnov (KS) drift assumes that the feature distribution functions for the production and training datasets are equal. However, if KS drift computes a greater distribution distance among two features, the relevant dataset is considered to have drifted.</p><p>Picsellia tracks drift over a long period to categorize drifts as sudden, incremental, or recurring. After classifying the drift type, the relevant dataset can be modified.</p><h3>Supervised Monitoring Metrics</h3><p>Supervised computer vision monitoring metrics need user input for measuring model performance. It usually requires manually verifying the real-world production data to observe any drastic changes that can result in performance degradation of the CV models. Following are some of the supervised monitoring metrics:</p><ul><li>Data Drift</li><li>Concept Drift</li><li>Domain Shift</li><li>Prediction Drift</li><li>Upstream Drift</li></ul><p>Let’s discuss them in detail.</p><ul><li><strong>Data Drift</strong></li></ul><p><a href="https://www.picsellia.com/post/what-is-data-drift-and-how-to-detect-it-with-mlops">Data drift</a> happens when the computer vision model is trained on images different from the real-world data given in production. It indicates the change in production set distribution and training data distribution, resulting in a model that underperforms. Some common methods to measure the distance between these distributions are:</p><ul><li>Wasserstein’s Distance</li><li>Kullback — Leibler divergence (KL divergence)</li><li>Population Stability Index (PSI)</li></ul><p>Variation in times or seasonal shifts can also lead to data drift. For instance, a dataset about roads built in Asia will highly vary from roads in Europe. Similarly, IoT sensor readings can vary in summer and winter, resulting in data drift.</p><ul><li><strong>Concept Drift</strong></li></ul><p>Concept drift occurs when the patterns on which the model was trained no longer hold and the relationship between input and output parameters changes. The model becomes less accurate or obsolete.</p><p>Concept drift can be incremental, where the model grows old without adapting to the changing requirements. There can be a sudden drift where the patterns twist, such as overnight consumer demand shifts during pandemic lockdowns or recurring drift influenced by seasonal changes during holidays or festive events.</p><p>Monitoring computer vision solutions for concept drift can help understand the model better for up-gradation to ensure accuracy and relevancy in the real world.</p><ul><li><strong>Domain Shift</strong></li></ul><p>Domain shift, also known as the distributional shift, happens when the training, validation, and test data are selected from a probability distribution different from the production data distribution.</p><p>Domain shift is hard to detect, and it can result in performance deterioration of models in production. Its impact can be observed on the out-of-sample predictions, which can be minimized by carefully curating test samples.</p><ul><li><strong>Prediction Drift</strong></li></ul><p>Prediction drift, also known as model drift, monitors the difference in the model’s predictions over a period of time. It reflects the change in prediction from the production dataset compared to the training set.</p><p>Ideally, if the production model is unchanged, it should produce similar inference on getting the same inputs. However, models degrade over time and make inaccurate predictions. It is essential to diagnose prediction drift before it negatively impacts customers or business goals.</p><ul><li><strong>Upstream Drift</strong></li></ul><p>Upstream drift, also known as operational data drift, indicates changes in the model’s data pipeline. A production set can have wrongly classified or mislabeled input images with significant differences from the training set.</p><p>Operational data drift issues are not very obvious. It can occur due to changes in data features or the occurrence of missing values, adversely affecting the performance of the production model.</p><h3>Streamline Computer Vision Model Monitoring in Production</h3><p>Computer vision models degrade over time and need continuous real-time upgrades. Common underlying data issues can weaken and even break the trained CV model pipelines. Therefore, it is important to build computer vision monitoring solutions and continuously track key computer vision monitoring metrics.</p><p>Picsellia offers detection and mitigation of all such issues within a single <a href="https://www.picsellia.com/post/creating-a-cvops-platform">end-to-end CVOps platform</a>. It provides supervised and unsupervised metrics to aid in monitoring and automates the feedback loop so that no data drifts go unnoticed.</p><p>If you want to leverage Picsellia’s CVOps platform for free, <a href="https://bit.ly/3shSsNh">book your trial</a> today! Until next time! 👋</p><h3>References</h3><ol><li><a href="https://arize.com/model-monitoring/#">https://arize.com/model-monitoring/</a></li><li><a href="https://fullstackdeeplearning.com/spring2021/lecture-11/">https://fullstackdeeplearning.com/spring2021/lecture-11/</a></li><li><a href="https://www.kdnuggets.com/2021/03/machine-learning-model-monitoring-checklist.html">https://www.kdnuggets.com/2021/03/machine-learning-model-monitoring-checklist.html</a></li><li><a href="https://deepchecks.com/machine-learning-model-monitoring-why-is-it-so-important-to-monitor-post-deployment/">https://deepchecks.com/machine-learning-model-monitoring-why-is-it-so-important-to-monitor-post-deployment/</a></li><li><a href="https://www.picsellia.com/post/what-is-data-drift-and-how-to-detect-it-with-mlops">https://www.picsellia.com/post/what-is-data-drift-and-how-to-detect-it-with-mlops</a></li><li><a href="https://www.statlect.com/machine-learning/domain-shift">https://www.statlect.com/machine-learninnewg/domain-shift</a></li><li><a href="https://evidentlyai.com/blog/machine-learning-monitoring-data-and-concept-drift">https://evidentlyai.com/blog/machine-learning-monitoring-data-and-concept-drift</a></li><li><a href="https://arize.com/model-drift/">https://arize.com/model-drift/</a></li><li><a href="https://towardsdatascience.com/mlops-model-monitoring-101-46de6a578e03">https://towardsdatascience.com/mlops-model-monitoring-101-46de6a578e03</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72781871b515" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/key-metrics-you-must-monitor-when-building-a-computer-vision-monitoring-solution-72781871b515">Key Metrics You Must Monitor When Building A Computer Vision Monitoring Solution</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Management in AI: Key Success Factor]]></title>
            <link>https://medium.com/picsellia/data-management-in-ai-key-success-factor-fb27a528151d?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb27a528151d</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 09:32:30 GMT</pubDate>
            <atom:updated>2022-04-15T09:33:59.939Z</atom:updated>
            <content:encoded><![CDATA[<p>A recent <a href="https://www.cognilytica.com/document/data-preparation-labeling-for-ai-2020/">Cognilytica study</a> states that the greatest challenge faced by most AI/ML teams is data management and optimization. About 50% of their time they spend in developing AI is on training data, while another 15% implies augmenting datasets to optimize processes around training data. In the long run, these optimizations can help them save a significant amount of money and time.</p><p><strong>Time Allocation in Machine Learning Tasks</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HtW7iMfcYLQztI6yNZKGOA.png" /><figcaption>Source: Data extracted from Cognilytica — Data Preparation &amp; Labeling for AI 2020</figcaption></figure><h3><strong>What is Data-Centric AI?</strong></h3><p>You’re probably well aware of the “Data-Centric” approach to AI, often referred to as DCAI. A lot of people have tried to define it. At Picsellia, we are aligned with Andrew Ng’s definition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lZ9-8poq3CpDiSIe" /></figure><p>We think that the key takeaway from his definition is the term “systematically”, which implies that data will always be the first thing to have in mind when starting a new project.</p><p>If you want to follow a Data-Centric AI approach, you should always ask yourself about the quality and quantity of your data before anything else. This means that all the interrogations about your model’s implementation should become, at least, secondary.</p><p><strong>What are the most important questions to achieve DCAI?</strong></p><ul><li>Do I have data for my use-case?</li><li>How much data do I have?</li><li>How relevant is the data ?</li></ul><h3><strong>You Need Data Management to be Data-Centric</strong></h3><p>Following the Data-Centric approach, it becomes obvious that the iteration speed of your computer vision models will be limited by the speed at which you iterate your data. The speed of access to information to answer these questions will be a key factor in your development process.</p><p>In order to maximize the agility of your organization around your data, an efficient and centralized data management system is a key success factor for your AI projects.</p><p>At Picsellia, we are convinced that a successful strategy in computer vision requires appropriate data management. The current complexity of AI lies in its operations and processes and not in model development.</p><h3><strong>Key Features For An Efficient Data Management Solution</strong></h3><p>Before, we mentioned the importance of centralization in data management. However, this is not the only element to consider when setting up our data management strategy.</p><p>Indeed, the objective is to be able to answer the before-mentioned three questions concerning data quantity, its relevance and quality. To achieve this, it’s necessary to set up tools that allow you to navigate as efficiently as possible in your data, and to extract relevant information. A poll we recently launched on LinkedIn shows that the most sought-after functionality when implementing a data management strategy is data mining.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/0*npcPFj7MjZg5SwOE" /></figure><p>Indeed, the advent of cloud object storage technologies (AWS s3, Google Cloud Storage, etc.) has allowed companies to store more and more data at a lower cost. But, when working on computer vision use-cases, centralized mass storage poses a major problem of visualization and exploration.</p><p>The unstructured character of an image makes navigation in these object-stores very complicated. Thus, one of the major functionalities required for a data management solution dedicated to computer vision is data visualization and exploration.</p><p>Then comes the traceability and versioning of your data. To let your organization reproduce and analyze your work, it is essential to keep a history of the use of data.</p><p>The development of computer vision models requires a total mastery and a 360° vision of the data that was used to create them. To sum it up, you need to be able to answer the following questions:</p><ul><li>What data was used to train model X?</li><li>Which dataset was used in experiment Y?</li></ul><h3><strong>Wrapping up</strong></h3><p>In order to guarantee the success of a Data-Centric strategy, it is necessary to set up an efficient data management system. Centralizing data via cloud storage solutions such as AWS s3 is not enough to get a data management system. You will also need to set up visualization, search and indexing functionalities to be able to answer the fundamental questions to a Data-Centric strategy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb27a528151d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/data-management-in-ai-key-success-factor-fb27a528151d">Data Management in AI: Key Success Factor</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MLOps Applied: How to Use Computer Vision in Cancer Cell Research]]></title>
            <link>https://medium.com/picsellia/mlops-applied-how-to-use-computer-vision-in-cancer-cell-research-516102ba89f1?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/516102ba89f1</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning-tools]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Mon, 28 Mar 2022 13:36:07 GMT</pubDate>
            <atom:updated>2022-03-29T08:36:22.385Z</atom:updated>
            <content:encoded><![CDATA[<p>We casted a webinar to introduce the new version of our platform, now centered on MLOps, and more precisely, on <a href="https://bit.ly/3wNngZ4">CVOps</a>–MLOps applied computer vision. At <a href="https://bit.ly/3Ns5ssf">Picsellia</a>, we offer an end-to-end computer vision (CV) platform that lets you manage AI data, run experiments, deploy models into production and monitor them with automated pipelines.</p><p>To introduce you to Picsellia’s new features, we’ve prepared a use-case in collaboration with the <a href="https://www.crct-inserm.fr/en/">Toulouse Cancer Research Center</a>. If you’d like to watch a replay of our webinar, it’s available on youtube, right <a href="https://youtu.be/UpwzH8bRRXQ">here</a>!</p><h3>Summary</h3><ol><li><a href="#26e3"><strong>About the use-case</strong></a></li><li><a href="#7cb0"><strong>Annotating your dataset</strong></a></li><li><a href="#79bb"><strong>Training your model</strong></a></li><li><a href="#69b6"><strong>Launching the experiment</strong></a></li><li><a href="#7309"><strong>Exporting the model</strong></a></li><li><a href="#6868"><strong>Deploying the model</strong></a></li><li><a href="#838b"><strong>Making predictions/inferences</strong></a></li><li><a href="#058a"><strong>Training a model on a custom dataset of fibroblast nucleus</strong></a></li><li><a href="#2f97"><strong>Continuous training and alert system</strong></a></li><li><a href="#aefa"><strong>Comparing shadow models</strong></a></li></ol><h3><strong>About the use-case</strong></h3><p>The use-case was possible thanks to the Toulouse Cancer Research Center, whose collaborators shared with us some of their obstacles for testing and researching.</p><p>The center is studying the propagation of cancer cells under microscopes, and researching how some other cells that are natively in our body, called fibroblasts, are helping cancer propagate.</p><p>Nowadays, what scientists measure regarding propagation is global fluorescence. By activating some enzymes on the cells, they can monitor the global fluorescence of an image. But, this fluorescence must be reported to the number of cells in the photo to have significant results.</p><p>Just counting the cells of an image, can take from 2–3 hours, up to 10–12 hours a week, hampering their research process.</p><p>At Picsellia, we thought that AI and computer vision could help them in detecting those cells’ nucleus and automating the cell counting process, bringing the 10-hour counting process to something like 2–3 minutes for a thousand of images.</p><h4>Methodology</h4><p>In short, we’ll try to train a new model that will serve as a base-model on our dataset, and we will fine tune it and use it to pre-annotate our images and see how it performs. Our dataset was suited for segmentation but we will use it for object detection just to make the use case simpler, and because object detection is suited for cell counting.</p><h3><strong>Annotating your dataset</strong></h3><p>We’ll start in the data lake. This is where all the assets stored can be viewed and searched, for example by tag or other attributes.</p><p>Here we have many more images than needed for our use case so we’re going to filter only the images from the Nature dataset, by the tag “nature”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MD7qasScE0UkRdPG10H11A.gif" /></figure><p>We see that we only list 79 images, which is the size of the original dataset. We can also switch to a list view and see the filename and attributes of images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gXasH6zam3vqZ1Df" /></figure><p>Now we need to select them all and create a Picsellia dataset that we’ll call “empty_images”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*HvwZI6o-GvCCFYfL" /></figure><p>As it should be created now, we can head to the dataset. Let’s select the dataset we want and the “empty_images” version we just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*is_ScjqUFRvwa9Nzec9adQ.gif" /></figure><p>In a dataset, you can import annotations. As the nature dataset was already labeled, we imported the annotations into a new version of our dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/0*943k9ZFWxMTxj4cp" /></figure><p>We go back to our datasets, and choose the one that is already annotated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*OUOvD8_-LplH6eDu" /></figure><p>Once there, we can visualize all the annotations that were made. The consistency looks pretty good and all the cells are labeled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n3HxszbpnJo8Ui8Y" /></figure><p>If we select one image and go to our annotation tool, if needed, we can edit the annotations one by one, or create a new annotation with our collaborative annotation interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8nb6geYsBgzWD2nuSQnLjQ.gif" /></figure><p>As shown next, in the data lake you can filter your images by attribute, including objects in the annotations. For example, we can choose to visualize all the images that contain more than 20 cells annotated, and see that it narrows down the number of images to 56.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_Rtng-L9YlwPHG7VJfTeQ.gif" /></figure><h3>Training Your Model</h3><p>Now that we are happy with our fully annotated dataset, we can move on to model training.</p><p>Let’s create a new project. We’ll call it base-nature-cells, invite our team, and validate it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8xazMREa8riUv3YgFoqdg.gif" /></figure><p>Next, we’ll attach the dataset we just created (with the annotations) to our project, and that will be the source of the experiment we’ll create right now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fNHxKoXp2tBGLyyviFifiQ.gif" /></figure><p>Let’s call it v0 and choose in our model HUB an <strong>efficientDet-d2 </strong>model suited for object detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V5cedwVdkitd57Dabl05PQ.gif" /></figure><p>We’ll keep the base parameters for now, select our dataset and create our experiment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PFFx5LA-ZndgwpGo" /></figure><p>This is our experiment dashboard. It’s empty for now but we can already check that it has attached all the resources we need, such as the base model, the dataset, and the parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*64RsZ4wGOI3ccBuL" /></figure><h3>Launching the experiment</h3><p>Now, we want to launch our experiment remotely just by going to the<strong> </strong>“launch” tab, and click the “launch” button. Picsellia already offers some packaged code for the models in our hub allowing us to launch training seamlessly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dRsuJZQd0q5mm82g" /></figure><p>We can now head to the “telemetry” tab where we can see the GPU server logs in real time and make sure that our model is training correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jINCsiSNxYD76E-93RjDcg.gif" /></figure><p>If we go back to the “logs” tab, we can see we already have some metrics such as train-split and the loss that is logged in real time during the training but has the activity history, which is the train/test split of the dataset and some epochs already for which we can check the loss in real time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_FSYiiBwFXUqDpft" /></figure><p>A few hours later, we want to check the “telemetry” tab. It took three hours for the experiments to finish.</p><p>Now we can see that our training is over and that everything has been logged correctly. We can even check thoroughly. In this case, we can observe that the evaluation and uploading of the artifacts went well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qIGVA3_ydsg7A_29i9BLbA.gif" /></figure><p>Let’s get back to our dashboard to see all our training metrics. Now we have much more information. We have all the charts from the different loss curves, our evaluation metrics, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JDsT3SP50ZaG7aeC" /></figure><p>We can observe that our loss seems to have reached a minimum, and say that it is good enough to the effects of this demo.</p><h3>Exporting the model</h3><p>Next, we want to export the experiment (click the “export” button at the top right). In other words, we’ll convert the experiment into a model and save it in our registry, that we will be able to deploy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-t8IalwFYDNWq-7y" /></figure><p>This leads us to our registry in the “model” page, where we can access the files it has to retrain or deploy, the label map, the training data and the original experiment.</p><h3>Deploying the model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jh-rs22W9Ts-wnoA" /></figure><p>Next, click on “deploy” and set a minimum confidence threshold to limit noise in our predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DNNFoKLwTGeIHVygxgl_Zg.gif" /></figure><p><strong>And we just created a deployed model!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eIY3EV-xLUlM_tyv" /></figure><h3>Making predictions / Inferences</h3><p>Now we want to make some predictions with our model, for which we just have to copy the name of the deployment and head down to a notebook or anywhere you can make an API call.</p><p>We will use our Python SDK to call our deployment. With a simple method we will authenticate and retrieve the deployment information. Then we’ll have to select a folder with images we want to perform predictions on, and send them to the model with the predict method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*Nc6fiyRpLtvW7hg3" /></figure><p>A great thing about Picsellia is that we can see predictions live in the dashboard. We have some simple but critical information such as the latency of the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9kTuesSMDFmK1coGgRdBw.gif" /></figure><p>Let’s send a few more just to trace a better chart.</p><p>We can see that our model has a mean latency of 210ms which is pretty good for a first step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BKpVTMOviGQNdDf4" /></figure><p>If we go to the “predictions” tab, we can now see all the predictions made by our model, (it should remind you of the Dataset tab).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*41wtc9tHNU6lr2RS" /></figure><p>As we can see, our model is detecting our cells but there is still a lot of noise in the predictions, so we’ll have to clean this for retraining another model.</p><p>Before reviewing, we will set up what we call the ‘feedback loop’ in our deployment settings, which sets a target dataset where our reviewed predictions will land.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ifgq7W8ckuS7iQ_M" /></figure><p>Now we can review our predictions. It’s basically the same process as labeling your data the first time, except that you can filter the predictions by confidence threshold and then edit the objects to make the annotations as neat and fast as possible.</p><p>If we go back to our dashboard, we will now have access to some more interesting metrics to ensure the quality of the model’s predictions. You will find pure object detection metrics such as average recall, average precision, the global and per prediction label distribution, information about image distribution and also automated data drift detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjZLDuhPszF82TSbjKN6VQ.gif" /></figure><p>Now, we have a base model that makes somewhat alright predictions, but our final goal is to train a model that will perform well on our custom dataset.</p><h3>Training a model on a custom dataset of fibroblast nucleus</h3><p>The process will consist of sending all the images through our model, which will do some pre-annotations, and then refine them to create a clean dataset to retrain a new model suited for our use-case.</p><p>Let’s predict our images. We can see that it did detect some of our nucleuses. Let’s go check those predictions closer.</p><p>Once again, we review and edit the new predictions the best we can–it is often pretty easy thanks to the threshold slider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0SntyIr9MFstPe5F2F1vKw.gif" /></figure><p>As you might remember, earlier, we set up in the settings of our deployment, what we call a feedback loop. This means that now that we’ve sent all our pictures through the model and reviewed them, they will all appear here and serve as training data.</p><p>We can see that the dataset consists of 30 images and has 712 objects annotated, which isn’t enough to train an object detection model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FqcraCqPpwJ_EPFY" /></figure><p>To enhance it, we will do some data augmentation with a script we prepared on the side, using some classic image manipulation, which leads us to this version of the dataset. The images have been randomly cropped, zoomed and rotated in order to create new samples easily. The dimensions look better now as we have nearly 700 images and 18000 objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*f3YXFnpz3I_OOtrzW_WdLA.png" /></figure><p>Now that we have our dataset, we will follow the same process as our first training. We’ll create a project and attach our augmented dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwhSqSYC9WpYh_VrVRiPtQ.gif" /></figure><p>And again, create an experiment that will handle the training part. For it, we will choose the same base model as earlier and create our experiment. Just to be clear, we didn’t want to use our pre-trained model from the base cells to train this one. The goal here was to use the first trained model to pre-annotate the data to help us go faster to the second iteration. That’s not what we did here–and that’s why we’re still using an <strong>efficientdet_d2</strong> architecture to train. But, another strategy would have been to use this model as the base architecture for our experiment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UsIAnv5WOpTf75Pg" /></figure><p>Once again, we’ll launch it remotely.</p><p><strong>Let’s check that our training runs correctly!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sriqyi7MQNfeDZwdUjfCng.gif" /></figure><p>We return to our project dashboard a couple of hours later, and we can see successful experiments. We have two because we were not satisfied with the performance of the first one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2xNaiYhpnPQffUQI" /></figure><p>Let’s take a look at the server logs to check that nothing went wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5eGb4L36bC8HbTVAZ4U7Vg.gif" /></figure><p>Again, we will also convert this experiment into a model in our registry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LrU5IEZcDB_xHQkp" /></figure><p><strong>Let’s create a new deployment.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5cRiNluM37rvB0Q7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TrsST4FULKrKbFhL" /></figure><p>We’ll set our same confidence threshold as before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qE63xH03xMscHRgy" /></figure><h3>Continuous training and alert system</h3><p>Then we’ll head to our new deployment. Before launching some predictions, we will first set up our deployments with some new features different from the previous one: the <strong>continuous training</strong> and the <strong>alert system</strong>.</p><p>Just to give some context, the continuous training is the ability to watch a trigger that will launch a simple experiment; in our case with some predefined parameters, base model and dataset. As we have all of our assets centralized in Picsellia, it’s really easy to do so.</p><p>In our case, for the sake of the webinar, we want the continuous training loop to launch after 3 new samples from the predictions are reviewed. We also have a default alert on the latency of the model that will send us some notifications if the latency goes beyond 100ms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6--9q6B8kDiRFqyh96rhcw.gif" /></figure><p>Now we’re going to set up default alerts that will be triggered on the latency of the model. If the model goes beyond 100 ms, we should see some alerts on the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tQeM7oGh0t55S_d_" /></figure><p>Now we are doing predictions with some original images that we kept on the side and see how our model performs. We can already see that our model triggered our alerts–its latency is 2 to 3 times greater than the 100 ms threshold we set earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i-hPpzbHyQsoihv7" /></figure><p>Next, we’ll review 3 images, in order to launch our continuous training loop.</p><p>Once we’ve done that, a training will be automatically launched in the project used to train the first model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7CuMeY6ToCEDE_n7SqLnQ.gif" /></figure><p>And, a couple of minutes later we can see that <strong>our experiment status is a success!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fy9BPob9ZfDt4r_G" /></figure><p>This means that if we go back to our deployment, we should see something new.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rFDigRI5Fu5pHlF9" /></figure><h3><strong>Comparing shadow models</strong></h3><p>The tab at the top of the screen is telling us that we have a new model ready from the continuous training loop, that can be deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hgBOIk3cS2BIzpMd" /></figure><p>We will deploy it as a <strong>shadow model</strong> to see how it performs against our first and current production model. In short, the shadow model will only be there to understand if it performs better than the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*i7wCi_IpKkXfl7xf" /></figure><p><strong>The model has been deployed successfully.</strong> Now we will make some predictions again, and we can see that we can directly compare our production model with the shadow model with no effort.</p><p>It looked like the shadow model had some latency issues at first but now has the same latency as our first model. And, if we take a closer look we can see that the mean latency of the shadow model is even better than the original one of tens of milliseconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HsnXxGPu7voZOb0mJywNog.gif" /></figure><p>If we want we can investigate a particular prediction by just clicking on any point in the chart. This helps us identify and better understand outliers coming from the prediction.</p><p>We can see that our shadow model seems to perform a little bit better than the previous one, just judging by its latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f6IjyEO1VSq1Vl7v" /></figure><p>We can go back to our prediction tab one last time and start to review some images to ensure the quality of the predictions of the shadow model–the same ground-truth will be compared between the prediction of the original model and the shadow model.</p><p>We can see that we have new metrics again in our dashboard, with information about the shadow model. This will help us to make the best decision on when to deploy the new model to production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47SoxeMmvXtSQtYFScjUzw.gif" /></figure><p>Here, if we just base our decision on the latency, we choose to promote the shadow model as a champion, and thus, our old model is no longer the production model and has been replaced by our shadow model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q1bGOX1lIDbBDIpYsvivVA.gif" /></figure><p>Finally, this closes the loop from training data, to deployment and monitoring for computer vision, which is what we call <a href="https://www.picsellia.com/post/how-to-apply-mlops-to-computer-vision-cvops">CVOps</a>.</p><p>In case you’d like to try Picsellia for free, you can directly book a quick call <a href="https://bit.ly/36sVgPT">here</a> so we can set you up!</p><blockquote>Originally posted in <a href="https://www.picsellia.com/blog">The Picsellia Blog</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=516102ba89f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/mlops-applied-how-to-use-computer-vision-in-cancer-cell-research-516102ba89f1">MLOps Applied: How to Use Computer Vision in Cancer Cell Research</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Train YOLOv5 on a Custom Dataset, Step by Step]]></title>
            <link>https://medium.com/picsellia/how-to-train-yolov5-on-a-custom-dataset-step-by-step-d14b39509952?source=rss-79cffa5c57d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/d14b39509952</guid>
            <category><![CDATA[yolov5]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Valentin]]></dc:creator>
            <pubDate>Thu, 17 Mar 2022 10:40:50 GMT</pubDate>
            <atom:updated>2022-04-12T08:47:48.222Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Note: The following video was recorded on Picsellia’s previous version in 2021, while this current blog article has been updated with Picsellia’s latest interface and newest MLOps features for computer vision (Updated: 17-March-2022)‍</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F7sGjmBNU6vI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D7sGjmBNU6vI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F7sGjmBNU6vI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c61710380948610357891a8712b67c95/href">https://medium.com/media/c61710380948610357891a8712b67c95/href</a></iframe><p>As an introduction, we’ll briefly walk through YOLO algorithms. For those who don’t know what YOLO is, it’s one of the most known object detection algorithms that has been achieving state-of-the-art results for quite a few years now.</p><p>The goal of this tutorial is to teach you how to train a YOLOv5 easily, by using our MLOps end-to-end platform in computer vision. But first, we’ll quickly cover its theory.</p><p><strong>This article will look as follows:</strong></p><ol><li><a href="#f7a7">Object-detectors evolution</a></li><li><a href="#8d6f">What is YOLO and how it’s different from other object detectors</a></li><li><a href="#94d0">How it performs</a></li><li><a href="#86b2">How to train YOLO v5 on your own custom dataset</a></li></ol><p>Let’s get started!</p><h3>Object-detectors evolution</h3><p>There are a few types of object detectors, R-CNNs and SSDs.</p><p>R-CNNs are Region-Based Convolutional Neural Networks. These are older, and are an example of two-stage detectors. The two stages are, a selective search that proposes a region, this is, bounding boxes that might contain objects; and a CNN used to classify this region. As you can see in the following figure, the two steps are done sequentially, which can take a lot of time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*7upVdVHbH_aF0pQ4.png" /></figure><p>The problem is that R-CNN’s first implementation in 2013 was really slow. This left a lot of room for improvement, and that’s what has been achieved in 2015 with Fast R-CNN, and later Faster R-CNN. These replaced the selective stage with Region Proposal Network (RPN), finally making R-CNN an end-to-end Deep Learning object detector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/0*VBBUmbT7TRIs0oqB.png" /></figure><p>This family of detectors usually throw pretty accurate results, but are quite slow. For this reason, researchers came up with a different architecture called Single Shot Detectors (SSD), which YOLO is part of.</p><h3>SSD Timeline</h3><ul><li>2015: YOLO (You Only Look Once)</li><li>2016: YOLO 9000</li><li>2018: YOLO v3</li><li>2020: YOLO v4</li><li>2020: YOLO v5</li></ul><h3>‍What makes those algorithms fast?</h3><p>They simultaneously learn the objects’ coordinates but also the corresponding classes. They are less accurate than R-CNN but much faster. That’s the philosophy behind YOLO and the many iterations known over the years.</p><p>Today we’re going to focus on the last one to date, YOLO v5. As you can see in the following graph, it really performs well, even against efficient debt, which is exponentially slower as you choose a higher version of it.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R2yKFY0MC5du_pt1.png" /></figure><h3>What does performance look like?</h3><p><strong>Pros</strong></p><ul><li>Much faster than R-CNN-based detectors</li><li>SOTA performance today with YOLO v5</li></ul><p><strong>Cons</strong></p><ul><li>Slightly less accurate than R-CNN</li></ul><p>As we can see next, there are multiple versions of YOLO v5 itself. It goes from small to extra large sizes, with obvious differences in weight, performance, and latency. This is good news because we can choose a version that is either very fast, but less accurate; or versions that are good compromises between latency and precision, and a heavier version that will perform better.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rB2SCkETOvcLQ6Ak.png" /><figcaption>Yolov5 sizes</figcaption></figure><p>Now that we’ve covered a little bit about YOLO and the main differences with other algorithms, <strong>let’s train it!</strong></p><h3>How to train YOLOv5 on a custom dataset</h3><p>For the record, <a href="https://www.picsellia.com/">Picsellia</a> is an end-to-end MLOps development platform that allows you to create and version datasets, annotate your AI data, track your experiments and build your own models. What is more, its newest version lest you deploy and monitor your models, and orchestrate pipelines to automate your AI workflows — all in the same place.</p><p>If you’d like to learn more about it, feel free to check out our <a href="https://documentation.picsellia.com/docs">documentation</a>, or schedule a quick call <a href="https://www.picsellia.com/contact?utm_source=Blogpost&amp;utm_medium=Tutorial+YOLO">here</a> with our team.</p><p>Without further ado, let’s get started!</p><h3>1. Create the dataset</h3><p>This is what the annotation interface looks like. We’ll choose a wine-grape dataset for our object detection project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0KiAE-Twe4s52Ihk.png" /><figcaption>Picsellia’s dataset interface</figcaption></figure><p>We can sort out the dataset this way to see further details, as shown next.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YJHZAHgJdlYiYB8U.png" /><figcaption>Picsellia’s dataset interface — different view</figcaption></figure><p>As you can see, the dataset is already fully annotated with 5 different classes, corresponding to different types of grapes.</p><p>If you click on the <strong>“Analytics”</strong> tab, you can get a better look of the data distribution and object by image distribution (among other metrics).‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rUv8SXJM65j8Y9YB.png" /><figcaption>Dataset analytics</figcaption></figure><p>Now, let’s take a look at the annotations. Back to the <strong>“Images”</strong> tab, we can select all the dataset, or just a subset of the images we want to label.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*EpC8_W-OkbmcNI3Q.png" /></figure><p>Our platform comes with a <a href="https://bit.ly/3CNpc4I">pre-annotated system and a robust AI labeling toolbox</a> that let you fully automate your annotations. This way, you can only keep the most accurate ones and optimize your training set.</p><p>As we can see next, the dataset is well annotated with every grape inside the bounding boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C9SbQV8t6tY58sxb.png" /></figure><p>You can select the images or subset you wish, to annotate, accept, reject or interact through comments and mentions with your colleagues. This way, you’ll make sure everyone is working on the same data. On a side note, Picsellia also comes with a “Review” system, where assigned collaborators can either accept or reject the labels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cV3KA32lM2QYCzJv.png" /><figcaption>Picsellia’s annotation interface</figcaption></figure><p>Now, for the sake of simplicity, we won’t create a model that can detect all those 5 classes, but rather, an object detector that can detect grapes in general. For that, we’ll merge the 5 classes into one that we’ll call “grape”, and create a new dataset version with it.</p><p>First, I’m going to select all my images and create a new dataset version with no labels (“Create blank”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/0*GDQ1_XF04wJl8kdT.png" /></figure><p>Once created, I’ll go back to the <strong>“Datasets</strong>” tab on the sidebar menu, and see my newest unlabeled version. I can see that I have various versions of my dataset. Now, let’s choose our newest version — “grape-no-label”, so we can set up the labels, and merge the different grape classes into just one (“grape”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RiO7M4SaT75QBT7B.png" /><figcaption>Dataset versions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iFb62yVAlMja_dMg.png" /><figcaption>Dataset interface — unlabeled images</figcaption></figure><p>‍Now, for setting up your labels, go to the tab <strong>“Settings” </strong>on the top screen, and select <strong>“New labels”.</strong>‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LNFuDZt5bUdjQfXC.png" /></figure><p>Next, choose your annotation class–in this case, Object Detection–, name it and add it as follows. Then, just hit <strong>“Create labels”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UlbsgIJ4up5N0ngF.png" /></figure><blockquote>Now it’s time to merge our labels!</blockquote><p>We’re gonna import the annotation from our old dataset into this version, and merge the 5 different labels into just one.</p><p>For that, click on <strong>“Annotations”,</strong> where we’ll select the version of the dataset we’d like to import our labels from. In this case, it’s the dataset called “first” that contains the 5 different grapes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_PmkuYQwNZiDY1i4.png" /></figure><p>Choose the output label “grape” as shown below, and select each one of the annotations to import as “grape” by clicking their checkboxes. Next, click “Execute instructions”.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dh8LzXIGShh4SWX4.png" /></figure><p>If we go to the <strong>“Settings” </strong>tag, we can see that our label is well defined as just one “grape”, and see it has the 3,920 objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hbZO99Wlvnk-XBTm.png" /><figcaption>Merged labels into just one class</figcaption></figure><p>Back to the Dataset interface (<strong>“Images”</strong> tab), we can see just <strong>one</strong> label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0t8Qi4W9fqck-2J3.png" /></figure><p>If we take a look at the annotations, we can observe that all our bounding boxes contain all different types of grapes, now labeled just as “grape”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O7mFDZXI8tsJLJ4o.png" /></figure><blockquote>Now, let’s get down to the real business:<strong> how to train a YOLOv5 on our custom dataset.</strong></blockquote><h3>2. Set up the training</h3><p>Let’s create a new project named “yolo-grape-test”, that uses this dataset and organizes my trainings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*puEWzWKDNStj3K9P.png" /></figure><p>At Picsellia you also have the option to invite team members to your project to work on the same data (we’re going to skip it for this tutorial).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d7i3NrNWuHzsNukz.png" /><figcaption>Invite your teammates to collaborate (just an option)</figcaption></figure><p>Just for the record, on the <strong>“All Projects”</strong> tab, on the sidebar menu, you’ll see all your projects stored in one single place.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zp2wl2aoMQiiHKVd.png" /><figcaption>Project</figcaption></figure><p>Project Hub‍</p><p>Now, let’s check our project. At this point, the project is pretty empty, so we’re going to attach the dataset we just created to this project, for which we’ll click <strong>“Open Datalake”.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2-_2U5rZEOhiI0Cz.png" /></figure><p>We then select our desired project, “Embrapa-wine-grape”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5uiRGcvNDx7xYdLQ.png" /><figcaption>Dataset selection</figcaption></figure><p>We want to choose our merged dataset version, “grape-one”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zTCZkHIzohaAz1gM.png" /></figure><blockquote>Great! Our dataset is now well attached!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f5ys1Mq242zeA0A7.png" /></figure><p>Next, before creating our experiment, let’s take a look at the <strong>Model</strong> section of Picsellia.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/0*fVR3ZXgEIduk4pCi.png" /><figcaption>Picsellia’s model hub</figcaption></figure><p>On this page you can find every model that we uploaded that are base architecture that you can use to kickstart your experiment, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VyTOpD1j4xv97-Mi.png" /><figcaption>Model hub</figcaption></figure><p>For our experiment, we’re going to use the <strong>YOLOv5-m</strong> model, for the sake of the speed of training. You can use this model out of the box, meaning, you don’t have to do anything, just select them.</p><blockquote>Now it’s time to go back to our project, and <strong>create our experiment using this pre-trained YOLOv5-m model.</strong></blockquote><p>Once there, we’re going to run our experiment with UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iqQWnjIwpotFQcT0.png" /></figure><p>This is going to be the first version of our training, named “v1”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H6eGT6NBmQ7X75pe.png" /></figure><p>And, on the second step, we’re going to choose the base architecture model from my “Organization HUB”. In this case, YOLOv5-m.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/0*ud9LF4aoMOuvDwdP.png" /></figure><p>To run YOLOv5-m, we just have to set up <strong>two parameters</strong>. The number of steps (or “epochs”) and the batch size.</p><p>For this tutorial, and to show it quickly, we’re just setting up 100 epochs. As we will run it in Colab, we’re going to set up a small batch size, 1, just for the test; and run it on a large hardware later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X5ECyIr3g-OOS2J-.png" /></figure><p>Lastly, we select our dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*S6hbHQfrV9UaWEpm.png" /></figure><p>Then we create the experiment, and we’ll see the experiment overview. We have our base model, our attached dataset, and our parameters are all set up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fMv5iyw1gIQWQgJQ.png" /></figure><p>The beauty of Picsellia is that in the <strong>“Launch” </strong>tab, we can choose different ways to launch our experiments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WfbSmhYH36ja4kaq.png" /><figcaption>Launch your experiments from anywhere.</figcaption></figure><p>We’ll be launching it with Google Colab, so by clicking there, we’ll access a preconfigured Jupyter notebook with all things needed to train a YOLOv5. I’m going to quickly show you all steps required to launch the training.</p><h3>3. Launching the training</h3><p>First, we have to install the Picsellia package, along with the Picsellia YOLOv5 package. In this library, we’ve packaged the whole PyTorch implementation of YOLOv5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HGpEL25SlYIaABFJ.png" /></figure><p>We have to import the packages along with PyTorch, os, subprocess, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B5lC0cu3YjfOkO5J.png" /></figure><p>We have to leverage the experiment system of Picsellia to get all the files we have from our pre-trained work and the parameters, so with the checkout we can get everything on the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VJ0axix5ZVw0ME_k.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LvnM1s-Dk9CmyWin.png" /></figure><p>Then, we need to download the annotations and images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3u5nVCwi_EdlQ2li.png" /></figure><p>We set up a directory that will store our images and annotations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*fEXLtC5PutxvOPqs.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c038woi5-3NkSFjf.png" /></figure><p>We then have to generate a yaml that will contain the label map along with the directory, the path of the training and test images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HjGZR_uX0HVZzn5v.png" /></figure><p>Next, we have to set up the hyperparameters that will be used for training, so the only things we have to give are the parameters we set up from Picsellia, the label map, and the experiment name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1D1hWlMz983QZLni.png" /></figure><blockquote><strong>And next, we can finally launch the training!</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*wEcEiTvsOrGnitnD.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*iwNB9E2PH5KnoZ2U.png" /></figure><p>We already launched it in order to show it to you, because it can be pretty slow on a Jupyter CPU notebook. But, as you can see, the training is going pretty well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OYRPPJpJhIRzKSeE.png" /></figure><blockquote><strong>And, everything is sent back to Picsellia, live!</strong></blockquote><p>As you can see next, I already have my training metrics live on the platform. If I refresh the page, I should have some more values, with the new epochs.</p><h3>4. Check the results‍</h3><p>Now, as it’d be too long to wait for the training to finish, and to show you real results with a longer training, I set up another training that I will show you next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qveKL9GO289r1TUV.png" /></figure><p>This one training has 1000 epochs as was trained on NVIDIA v100 GPUs. As you can see, the metrics are pretty good.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RKqwCRhEcn8tmC59.png" /><figcaption>We do have problems with our loss here–we should investigate it later–, but as you can see, it does converge a little bit.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cez7lMXlE_a2cxT_.png" /></figure><p>Now, let’s see results with evaluation on real images from our dataset. For this, I logged the images from my evaluation on different batches of images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VpxXy6vFLBWheLnb.png" /></figure><p>I downloaded one of these images. We do already have some great results for our great detection algorithm!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OQkQCLnjI4XcNPBX.png" /></figure><p>As an example, if we did just 1000 epochs (or “steps”) of training, the whole training process could take up to 4 hours. While, for our original test, where we only set up 100 epochs, that could take only a few minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cg4W1bebIe-WVwHs.png" /></figure><p>If we go check the files of our experiment, we have successfully uploaded all the files needed to resume our training later.</p><p>We need the config file, which is the yaml; a checkpoint file for hyperparameter; and another checkpoint file which is the PyTorch weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yo_JvE_COIdog0hx.png" /></figure><p>Now, we can resume our training whenever we want and iterate over and over on our experiments easily using <a href="https://www.picsellia.com/">Picsellia</a>.</p><p>If you’d like to try Picsellia for free and leverage our latest MLOps features (model deployment, monitoring, automated pipeline orchestration, and more), request your 14-day trial <a href="https://www.picsellia.com/14-day-free-trial">here</a>!</p><blockquote>Originally published on <a href="https://www.picsellia.com/post/how-to-train-yolov5-on-a-custom-dataset">The Picsellia Blog</a></blockquote><p>‍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d14b39509952" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picsellia/how-to-train-yolov5-on-a-custom-dataset-step-by-step-d14b39509952">How to Train YOLOv5 on a Custom Dataset, Step by Step</a> was originally published in <a href="https://medium.com/picsellia">Picsellia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>