<?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 Yuki Ng on Medium]]></title>
        <description><![CDATA[Stories by Yuki Ng on Medium]]></description>
        <link>https://medium.com/@yuking_97236?source=rss-99c1db247f15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lKyhsi1fJuIJOkTtiycrSg.jpeg</url>
            <title>Stories by Yuki Ng on Medium</title>
            <link>https://medium.com/@yuking_97236?source=rss-99c1db247f15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:31:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yuking_97236/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[Streamline Your Computer Vision Deep Learning Projects: 5 Open Source Tools You Should Know Before…]]></title>
            <link>https://medium.com/@yuking_97236/streamline-your-computer-vision-deep-learning-projects-5-open-source-tools-you-should-know-before-052e3933decb?source=rss-99c1db247f15------2</link>
            <guid isPermaLink="false">https://medium.com/p/052e3933decb</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Yuki Ng]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 11:03:06 GMT</pubDate>
            <atom:updated>2023-10-29T11:03:06.866Z</atom:updated>
            <content:encoded><![CDATA[<h3>Streamline Your Computer Vision Deep Learning Projects: 5 Open Source Tools You Should Know Before You Start</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OlZfVjCjPQV1IAm7" /><figcaption>Photo by <a href="https://unsplash.com/@xoforoct?utm_source=medium&amp;utm_medium=referral">EJ Strat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s truly a special moment when you see your Deep Learning Model in action. However, navigating the ever-changing landscape of real-world data, especially in the visual domain, can be a rollercoaster ride. As a dedicated Machine Learning Engineer, I’d say a whopping 99% of my time is spent scouring for those incredible libraries that can give me the edge I need.</p><p>And let me tell you, the availability of these powerful open-source tools and frameworks has been an absolute game-changer. They’re not just efficiency boosters; they’re like trusty sidekicks that help us confidently take on even the most intricate projects. Without further ado, let’s dive into the<strong> five Python libraries</strong> that have truly been my knights in shining armor throughout countless projects!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fo51U94zKaz9gWUckLp%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fparamountplus-101-pinkladies-riseofthepinkladies-o51U94zKaz9gWUckLp&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExc2QycWsxcG40OHNmY3M1ZG1ndWw2NHljdDFydW9jNTY5Z285MmF2dyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Fo51U94zKaz9gWUckLp%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/318df0c546ae060dcbf1590249ad515c/href">https://medium.com/media/318df0c546ae060dcbf1590249ad515c/href</a></iframe><h3>OpenCV: The Foundation of Computer Vision</h3><p>Yeah I know, you may ask, it is a common and well-known library and why bother to introduce it?</p><p>If you are a beginner just starting with your first Computer Vision Project and are looking for libraries, this is definitely the first one to check out as you may use it most of the time when dealing with video I/O operation or some basic image processing.</p><p><a href="https://opencv.org/">OpenCV</a>, an open-source computer vision and machine learning library, is the cornerstone of any computer vision project. It provides a wide range of tools and algorithms for tasks like image and video processing, feature extraction, object detection, and more. OpenCV’s robustness and extensive features make it a must-have tool for every computer vision engineer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*ojSBdDGF6ZMm_OumAwxy0Q.png" /><figcaption><a href="https://opencv.org/">https://opencv.org/</a></figcaption></figure><p>Here’s a basic video reading example on OpenCV:</p><pre>import numpy as np<br>import cv2 as cv<br>cap = cv.VideoCapture(&#39;video.avi&#39;)<br><br>while cap.isOpened():<br>     ret, frame = cap.read()<br>     if not ret:<br>     print(&quot;No frame&quot;)<br>     break<br>     gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)<br>     cv.imshow(&#39;frame&#39;, gray)<br>     if cv.waitKey(1) == ord(&#39;q&#39;):<br>     break<br><br>cap.release()<br>cv.destroyAllWindows()</pre><blockquote><strong><em>TL;DR —</em></strong> Begin your project by leveraging OpenCV’s functionalities for tasks like data preprocessing, image manipulation, and basic feature extraction.</blockquote><h3>FiftyOne: Data Exploration and Analysis</h3><p>After collecting substantial amounts of visual data, the first step is to <strong>explore and analyze the data</strong>. This crucial phase grants you deeper insights into the details of your image dataset. Understanding the characteristics, patterns, and potential challenges within your data sets the stage for a more informed and effective approach to your computer vision project.</p><p>Furthermore, before beginning the training process, it is imperative to thoroughly <strong>clean the data</strong>. This involves filtering out any low-quality or erroneous images. By ensuring that your dataset is composed of high-quality, relevant visuals, you lay the foundation for robust model performance and accurate predictions.</p><p><a href="https://github.com/voxel51/fiftyone">FiftyOne</a>, by Voxel51, is a Python library designed to assist in visualizing, analyzing, and understanding computer vision datasets. It provides an interactive interface to explore images, view annotations, and perform statistical analysis on your data. FiftyOne streamlines the data preparation phase, enabling you to gain valuable insights into your dataset’s characteristics. Not only that, it provides a <a href="https://docs.voxel51.com/user_guide/dataset_zoo/index.html"><strong>Dataset Zoo</strong></a> and <a href="https://docs.voxel51.com/user_guide/model_zoo/index.html"><strong>Model Zoo</strong></a> so that you can get access to public datasets and pre-trained models easily with just one line of code!</p><p>For example, if you would like to get 50 images of <em>Tortoise</em> and <em>Apple</em> with a detection box from <a href="https://storage.googleapis.com/openimages/web/index.html"><strong>Open Images Dataset V7</strong></a>:</p><pre>import fiftyone as fo<br>import fiftyone.zoo as foz<br><br>dataset = foz.load_zoo_dataset(<br>    &quot;open-images-v7&quot;,<br>    label_types=[&quot;detections&quot;],<br>    classes = [&quot;Tortoise&quot;, &quot;Apple&quot;],<br>    max_samples=50,<br>)<br><br>session = fo.launch_app(dataset)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4b2DlGII34SWWP72T-77w.png" /><figcaption>Open Image Dataset V7 Visualization in FiftyOne</figcaption></figure><p>You can then visualize the images that contain the <em>Tortoise</em> and <em>Apple</em> with the bounding boxes for further processing.</p><blockquote><strong><em>TL;DR — </em></strong>Employ FiftyOne to gain a comprehensive understanding of your dataset, visualize annotations, and perform statistical analysis on image attributes.</blockquote><h3>CVAT: Annotation Tool for Labeling</h3><p>Alright, once you’ve had a good look at your data, it’s time to start annotating those images to fit your needs! Labeling data is like getting the ground truth answers for the model so that the computer can learn what’s what. It’s super important for training your computer vision models. But I won’t lie, it can be a bit of a time-sucker throughout your project. That’s why we need a better tool to accelerate the whole annotation process.</p><p>CVAT (Computer Vision Annotation Tool) is an open-source web-based tool that simplifies the process of annotating images and videos. It supports various annotation types like <strong>bounding boxes, polygons, and key points</strong>. CVAT’s user-friendly interface and collaborative capabilities make it an excellent choice for teams working on labeling tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*3LvIlRNG2MtN9CQc.gif" /><figcaption>Source: <a href="https://github.com/opencv/cvat">https://github.com/opencv/cvat</a></figcaption></figure><p>What’s more, it supports <strong>serverless automatic automation</strong> to automatically pre-annotate your data with pre-trained models, such as Segment Anything (SAM), and YOLO v7! Here’s a full deep-learning model list that CVAT supports for automatic labeling:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*14BXWOx14HhpHcclkEqk1w.png" /><figcaption>A full list that CVAT supports for automatic labeling. Source: <a href="https://github.com/opencv/cvat">https://github.com/opencv/cvat</a></figcaption></figure><p>Another standout feature is <strong>CVAT’s seamless integration with FiftyOne</strong>, as I mentioned earlier. What’s particular is that FiftyOne offers an API that allows you to effortlessly create tasks and jobs, upload data, set up label schemas, and retrieve annotations from CVAT, all with the power of Python. When you bring these two tools together, you’ve got a powerful combo that lets you quickly review annotations post-labeling. This ensures top-notch image quality throughout the process. This integration takes the hassle out of quality assurance, giving you confidence in your annotated data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F76yCDV7ez1dSGKASc1%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fcheers-teamwork-andy-stoffo-76yCDV7ez1dSGKASc1&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZHBvNzc0eXdvbXlwam5yMzZlc3BpbG1wamFmdmtoaGZkMjJ0cm1keCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F76yCDV7ez1dSGKASc1%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/348841d2d3c5c297965c4663ec7488f3/href">https://medium.com/media/348841d2d3c5c297965c4663ec7488f3/href</a></iframe><blockquote><strong><em>TL;DR —</em></strong> Integrate CVAT into your workflow to efficiently label images and videos, ensuring high-quality training data for your computer vision models.</blockquote><h3>PyTorch Lightning: Simplified Deep Learning</h3><p>Now, let’s dive into the exciting part — training the model! But wait, there’s a bit more groundwork to cover before we hit that training button. We need a data loader, a scheduler, setting up learning rate, etc… You see, when it comes to training models, it’s not just about throwing data at them and hoping for the best. This is where PyTorch Lightning steps in as a game-changer.</p><p>PyTorch Lightning is a lightweight PyTorch wrapper that simplifies the training and deployment of deep learning models. It streamlines the entire process, providing a structured framework and best practices, allowing you to focus on building models and experimentation rather than boilerplate code. PyTorch Lightning’s modular design and extensive community support make it a powerful tool for accelerating your computer vision projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*nHZu4ji-2niV4wLJjSJMVg.png" /></figure><p>A great example from PyTorch Lightning&#39;s official documentation:</p><pre>import torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, torch.nn.functional as F<br>import lightning as L<br><br># --------------------------------<br># Step 1: Define a LightningModule<br># --------------------------------<br># A LightningModule (nn.Module subclass) defines a full *system*<br># (ie: an LLM, diffusion model, autoencoder, or simple image classifier).<br><br><br>class LitAutoEncoder(L.LightningModule):<br>    def __init__(self):<br>        super().__init__()<br>        self.encoder = nn.Sequential(nn.Linear(28 * 28, 128), nn.ReLU(), nn.Linear(128, 3))<br>        self.decoder = nn.Sequential(nn.Linear(3, 128), nn.ReLU(), nn.Linear(128, 28 * 28))<br><br>    def forward(self, x):<br>        # in lightning, forward defines the prediction/inference actions<br>        embedding = self.encoder(x)<br>        return embedding<br><br>    def training_step(self, batch, batch_idx):<br>        # training_step defines the train loop. It is independent of forward<br>        x, y = batch<br>        x = x.view(x.size(0), -1)<br>        z = self.encoder(x)<br>        x_hat = self.decoder(z)<br>        loss = F.mse_loss(x_hat, x)<br>        self.log(&quot;train_loss&quot;, loss)<br>        return loss<br><br>    def configure_optimizers(self):<br>        optimizer = torch.optim.Adam(self.parameters(), lr=1e-3)<br>        return optimizer<br><br><br># -------------------<br># Step 2: Define data<br># -------------------<br>dataset = tv.datasets.MNIST(&quot;.&quot;, download=True, transform=tv.transforms.ToTensor())<br>train, val = data.random_split(dataset, [55000, 5000])<br><br># -------------------<br># Step 3: Train<br># -------------------<br>autoencoder = LitAutoEncoder()<br>trainer = L.Trainer()<br>trainer.fit(autoencoder, data.DataLoader(train), data.DataLoader(val))</pre><p>Not only that, PyTorch Lightning provides a convenient way to incorporate advanced features into your training pipeline. For example, early stopping is a technique that monitors the model’s performance on a separate validation set and stops training once the validation performance plateaus or starts to degrade. This prevents the model from becoming overly specialized to the training data.</p><p>PyTorch Lightning offers a built-in callback for early stopping that can be easily integrated into your training loop. This means you don’t have to implement the early stopping logic from scratch, saving you time and effort:</p><pre>es = EarlyStopping(monitor=&quot;val_loss&quot;)<br>trainer = Trainer(callbacks=[es])</pre><p>If you would like to know more about lightning, check the quickstart here:</p><p><a href="https://lightning.ai/docs/pytorch/stable/starter/introduction.html">Lightning in 15 minutes - PyTorch Lightning 2.1.0 documentation</a></p><blockquote><strong><em>TL;DR —</em></strong> Leverage PyTorch Lightning to structure your deep learning models, manage experiments, and streamline the training process for your computer vision tasks.</blockquote><h3>Gradio: Easy Deployment of Models</h3><p>Now that you’ve trained your models, it’s time to showcase them! This means we’ll need a user interface. Traditionally, this might require some front-end programming skills, like CSS, HTML, and JavaScript. As someone who uses Python as a primary language, does this mean that you have to devote a lot of your time and energy to learning extra front-end skills?</p><p>Fret not! Enter Gradio to the rescue, <strong>all within Python</strong>.</p><p><a href="https://www.gradio.app/"><strong>Gradio</strong></a> is a user-friendly library that simplifies the deployment of machine learning models. It provides a simple interface for building interactive web applications to showcase your computer vision models. Gradio supports a wide range of input and output formats, such as</p><ul><li>Text</li><li>Image</li><li>Chatbox</li><li>Slider</li></ul><p>making it easy to create user-friendly interfaces for your models without extensive front-end development. If you have ever tried some famous ML apps in <a href="https://huggingface.co/spaces">Hugging Face Spaces</a>, you definitely notice they are built with Gradio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*52VgDotgs16WMRKF.gif" /><figcaption>Common input types in Gradio. Source: <a href="https://github.com/gradio-app/gradio">https://github.com/gradio-app/gradio</a></figcaption></figure><p>Here’s a toy example of inputting an image and apply sepia filter to it:</p><pre>import numpy as np<br>import gradio as gr<br><br># sepia filter - photographic effect that <br># imparts a warm, brownish tone to an image<br>def sepia(input_img):<br>    sepia_filter = np.array([<br>        [0.393, 0.769, 0.189], <br>        [0.349, 0.686, 0.168], <br>        [0.272, 0.534, 0.131]<br>    ])<br>    sepia_img = input_img.dot(sepia_filter.T)<br>    sepia_img /= sepia_img.max()<br>    return sepia_img<br><br>demo = gr.Interface(sepia, gr.Image(shape=(200, 200)), &quot;image&quot;)<br>demo.launch()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xIOMRboIS-cWgbTA.gif" /><figcaption>Source: <a href="https://github.com/gradio-app/gradio">https://github.com/gradio-app/gradio</a></figcaption></figure><blockquote><strong><em>TL;DR —</em></strong> Integrate Gradio into your project to deploy your computer vision models, allowing users to interact with them through a web interface.</blockquote><h3>Conclusion</h3><p>By combining these five open-source tools, you can create a robust pipeline for end-to-end computer vision projects. Start with OpenCV for foundational tasks, use FiftyOne for data exploration and analysis, employ CVAT for efficient annotation, streamline deep learning with PyTorch Lightning, and deploy your models with Gradio. Whether you are a beginner or an experienced practitioner, this toolkit provides a comprehensive framework to tackle a wide range of computer vision applications.</p><p>Thank you so much for reading this article! I hope you found it both enjoyable and enlightening. If you’d like to explore more content like this, feel free to give me a follow or a clap so that I can write more on this.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FSwx36wwSsU49HAnIhC%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FSkyTV-harry-potter-drinking-slide-in-dms-Swx36wwSsU49HAnIhC&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZjQ4Nmx6ZmlueGdpeGtkcnIxODRqYmFsNXBrMjh4YTB4NW5xbzk5bSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FSwx36wwSsU49HAnIhC%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bc7013380ab630cd0b1e28939bda3bb/href">https://medium.com/media/3bc7013380ab630cd0b1e28939bda3bb/href</a></iframe><p>In the future, I’ll be diving into even more exciting Deep Learning and Computer Vision concepts as well as practical examples, so stay tuned!</p><p>That’s all for today! Keep learning 📚 and stay curious! 😊</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=052e3933decb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>