<?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 Snowshow on Medium]]></title>
        <description><![CDATA[Stories by Snowshow on Medium]]></description>
        <link>https://medium.com/@snowshow4?source=rss-c9634e01f9fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5PENym1f00fuERgL</url>
            <title>Stories by Snowshow on Medium</title>
            <link>https://medium.com/@snowshow4?source=rss-c9634e01f9fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:06:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@snowshow4/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[UMatcher: A Lightweight Modern Template Matching Model for Edge Devices]]></title>
            <link>https://medium.com/@snowshow4/umatcher-a-lightweight-modern-template-matching-model-for-edge-devices-8d45a3d76eca?source=rss-c9634e01f9fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d45a3d76eca</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[object-tracking]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[template-matching]]></category>
            <dc:creator><![CDATA[Snowshow]]></dc:creator>
            <pubDate>Sat, 07 Jun 2025 03:44:08 GMT</pubDate>
            <atom:updated>2025-06-07T03:44:08.214Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*McQIInAFn2yQHlYaFAmjZg.jpeg" /><figcaption>One-Shot Object Detection Using UMatcher</figcaption></figure><h3>Abstract</h3><p>Mobile devices are inherently limited in computational power, posing challenges for deploying robust vision systems. Traditional template matching methods are lightweight and easy to implement but fall short in robustness, scalability, and adaptability — especially in multi-scale scenarios — and often require costly manual fine-tuning. In contrast, modern visual prompt-based detectors such as DINOv and T-REX exhibit strong generalization capabilities but are ill-suited for low-cost embedded deployment due to their semi-proprietary architectures and high computational demands.</p><p>To address this trade-off, we introduce UMatcher, a novel framework designed for efficient and explainable template matching on edge devices. UMatcher combines:</p><p><em>A dual-branch contrastive learning architecture to produce interpretable and discriminative template embeddings</em></p><p><em>A lightweight MobileOne backbone enhanced with U-Net-style feature fusion for optimized on-device inference</em></p><p><em>One-shot detection and tracking that balances template-level robustness with real-time efficiency</em></p><p>This co-design approach strikes a practical balance between classical template methods and modern deep learning models — delivering both interpretability and deployment feasibility on resource-constrained platforms.</p><h3>DINOv, T-Rex, Visual Prompt</h3><p>When deploying models on edge devices, we often encounter scenarios that require few-shot detection or tracking. One popular solution in this space is YOLO-World, which has recently gained a lot of attention. However, YOLO-World is fundamentally designed as an open-vocabulary detector based on language prompts. In real-world applications, this can become a limitation — many targets simply can’t be accurately described using language alone.</p><p>To tackle this challenge, the IDEA team proposed the DINOv and T-REX series, which introduce visual prompts to provide more precise and controllable target specifications. As the saying goes, <em>“a picture is worth a thousand words”</em> — and these approaches have made significant progress by embracing that principle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nK_p2QekAgn0QirKovUXeQ.png" /><figcaption>T-Rex Web Demo</figcaption></figure><p>The official T-REX project provides a <a href="https://link.zhihu.com/?target=https%3A//cloud.deepdataspace.com/playground/ivp">live demo</a> website where users can explore example results or upload their own images for testing — and the actual performance is nothing short of impressive. One particularly noteworthy feature is T-REX’s support for positive and negative sample annotation.</p><p>If the model mistakenly detects irrelevant objects (false positives) or misses intended targets (false negatives), users can refine the results by adding those cases as negative or positive samples, respectively. This interactive visual prompt mechanism empowers users to fine-tune the detector toward their specific needs — enabling precise localization of arbitrary targets while continuously improving performance.</p><p>After experiencing the demo, many users (myself included) may come to the same realization:</p><blockquote>Object Detection is Dead.</blockquote><p>As impressive as T-REX may be, we eventually have to return to the realities of daily work and consider how to apply its powerful detection capabilities to our own projects. In my case, the focus is on deploying embedded vision models on mobile devices to perform specific detection tasks.</p><h3>Practical Needs, Application Limits, and Template Matching</h3><p>The new version of DINOv — <strong>DINOv1.5</strong> — has introduced some optimizations for mobile deployment. On an NVIDIA Orin NX, for example, it can achieve around <strong>10 FPS</strong> inference speed at a resolution of 640×640. However, the model currently appears to be <strong>semi-closed-source</strong>, offering only API-level access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*Ty2atviX05_RDgy0LH5roQ.png" /><figcaption>DINOv1.5 Model Architecture [src:<a href="https://arxiv.org/abs/2405.10300">DINOv1.5 pape</a>r]</figcaption></figure><p>Even though DINO does provide training code, most users lack the large-scale datasets or computational resources needed to train custom models from scratch. As a result, while the ideas behind DINO are certainly inspiring, <strong>adapting them directly into real-world, resource-constrained projects remains a significant challenge</strong>.</p><p>In addition, I conducted a more rigorous test using a proprietary dataset from my own project on the T-REX demo platform. The results revealed that the model still has <strong>significant room for improvement</strong> in terms of <strong>false negatives</strong> and <strong>false positives</strong>.</p><p>In fact, the T-REX team positions the model more as an <strong>auto-annotation tool</strong> rather than a deployable detector. Their recommended use case is to leverage T-REX for generating high-quality annotations, which can then be used to train a custom, task-specific model. In real-world deployments, users are expected to run their own lightweight models — essentially using T-REX as a <strong>powerful teacher model</strong>, guiding the training process via <strong>knowledge distillation</strong>.</p><p>Now, let’s take a closer look at how well the T-REX family of models aligns with the visual tasks I’m currently working on.</p><p>To begin with, even the <strong>Edge version of DINOv1.5</strong> only manages around <strong>10 FPS</strong> on the <strong>NVIDIA Orin NX</strong> — which is far from ideal for scenarios that demand real-time performance. Moreover, Orin NX itself remains <strong>too expensive</strong> for many cost-sensitive projects.</p><p>In reality, a wide range of deployments are happening on more affordable embedded platforms such as <strong>SX1684</strong>, <strong>Atlas 200</strong>, <strong>RK3588</strong>, or even <strong>Allwinner T527</strong> and the <strong>Raspberry Pi</strong>. For these platforms, computational resources are far more constrained, making large models impractical for production use.</p><p>Let’s return to the nature of our actual tasks: in most cases, the application is deployed in <strong>highly constrained environments</strong> and performs relatively <strong>simple detection</strong>. Examples include detecting specific objects from a fixed angle on an assembly line, checking for the presence of a particular toy, or locating a specific icon in a screen capture.</p><p>These scenarios <strong>don’t require the full generalization power</strong> of large-scale object detectors. Instead, what matters more is <strong>reliability, speed, and integration</strong> — as the detection results are often just one part of a larger system pipeline.</p><p>In essence, these tasks are more akin to using the vision model as a <strong>domain-specific visual sensor</strong> that outputs targeted signals, rather than a full-fledged general-purpose detector.</p><p>For the types of tasks mentioned above, <strong>template matching</strong> is often the go-to solution. However, direct pixel-based methods — such as <strong>Normalized Cross-Correlation (NCC)</strong> or functions like matchTemplate from <strong>pyautogui</strong> or <strong>OpenCV</strong>—often suffer from <strong>limited robustness</strong>.</p><p>To improve performance, additional features like <strong>SIFT</strong>, <strong>ORB</strong>, or <strong>color histograms</strong> are commonly introduced to complement and fine-tune the matching process. When dealing with scale variations, developers often resort to <strong>sliding windows</strong> and <strong>image pyramids</strong> to increase detection flexibility.</p><p>In real-world applications, though, these enhancements can introduce <strong>significant debugging overhead</strong>. The process becomes especially frustrating when seemingly obvious template matches fail to reproduce reliably on deployed machines.</p><p>(Of course, projects like the <a href="https://landing.ai/videos/vision-agent-in-action"><strong>Vision Agent</strong></a> from Andrew Ng’s team may offer a new direction for alleviating the debugging pain of vision engineers. But based on early testing, its strengths currently lie in <strong>rapidly generating code scaffolds</strong>, while deeper performance tuning and robustness adjustments still <strong>require manual intervention</strong>.)</p><p>Given these challenges, a natural question arises:</p><p><strong>Can we build a better template matching solution using today’s available technologies?</strong></p><p>Such a solution may not match the <strong>generalization power</strong> of something like DINO — but it should at least offer <strong>robustness more aligned with human visual perception</strong>, making it significantly easier to deploy and debug in real-world conditions.</p><h3>UMatcher</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OY-WOjUIKxXrmEQ-QU-RbA.png" /><figcaption>UMatcher</figcaption></figure><p>UMatcher is a modern template matching model specifically designed to address the challenges mentioned above. The model draws inspiration from single-object tracking architectures like SiamFC and adopts a dual-branch design consisting of a Template Branch and a Search Branch.</p><p>During inference, the template image is fed into the Template Branch and processed into a template embedding vector. Meanwhile, the search image passes through the Search Branch for feature extraction. These features are then fused within a subsequent U-Net structure.</p><p>Finally, a detection head (note: this is not a Transformer-based DETR architecture and requires post-processing with Non-Maximum Suppression) produces the matching results.</p><p>A key highlight is that during training, the Template Branch incorporates contrastive learning. This enables the extracted template embedding vectors to be highly interpretable and flexible to use, opening up several practical applications:</p><p>Aggregating multiple template embeddings by averaging to achieve more stable detection results;</p><p>Using the Template Branch independently for classification tasks by computing cosine similarity or integrating with a KNN classifier;</p><p>Monitoring target appearance changes in real-time during tracking to assist dynamic adjustment of tracking strategies.</p><p>This ability to interpret and flexibly leverage the template embeddings is one of the core features that sets UMatcher apart from traditional template matching methods.</p><h4>Mobile-Friendly Design</h4><p>Moreover, the model design specifically considers deployment requirements on mobile devices and NPUs:</p><p>Backbone choice: The model uses Apple’s MobileOne as the backbone. After reparameterization, MobileOne retains only standard convolutions (Conv) and ReLU activations, avoiding specialized operators like Depthwise Conv or SE modules. This is especially beneficial for devices with dedicated NPU acceleration platforms — such as the RK3588 — because Conv and ReLU are fundamental operators typically supported natively and highly optimized on most NPUs. In contrast, specialized operators often suffer from lower efficiency and may even require developers to implement custom CPU fallback code.</p><p>Feature fusion design: Feature fusion employs a U-Net structure, also optimized for deployment. Unlike many single-object tracking models that rely on dynamic convolution or correlation operations, UMatcher’s U-Net uses only basic operators such as concatenation (Concat), convolution (Conv), transposed convolution (ConvTranspose), ReLU, and a final sigmoid activation.</p><p>This simple architecture relying solely on widely supported, fundamental operators greatly reduces deployment complexity and costs on mobile platforms equipped with specific NPUs, while fully leveraging the most mature and efficient optimization solutions provided by platform vendors.</p><h4><em>Synthetic training data</em></h4><p>Regarding training data, UMatcher primarily relies on synthetic data for training. The model can be trained end-to-end using datasets like COCO or SA-1B (or subsets thereof).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbwmMrpBJFxP3LG6FHQsoQ.png" /><figcaption><em>Synthetic training data example (template, search image 1, search image 2)</em></figcaption></figure><p>Analyzing the synthetic data samples (as shown in the figure), two key design features stand out:</p><p>Support for presence detection: The dataset includes an increased number of search images that do not contain the target object (marked with blue boxes in the figure), representing cases where no matching target is present.</p><p>Support for multi-object scenarios: Single search images may contain multiple targets (red boxes indicate ground truth annotations (GT), green and cyan boxes represent model predictions (PD), and the green mosaic area shows the predicted heatmap distribution). This design contrasts with typical single-object tracking datasets — which usually contain only one target — and aims to enable UMatcher to effectively perform detection and counting tasks.</p><p>The final test results are as follows — UMatcher successfully achieves one-shot detection and single-object tracking as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILMNqYCtA40ewB2M83icTw.png" /><figcaption>One-Shot Object Detection</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*PTsOykvlyhTzJIHD6JQwIg.gif" /><figcaption>Object Tracking</figcaption></figure><p>(Note: For detection on higher-resolution images, a combination of image pyramids and sliding windows was used; for tracking, a simple Kalman filter was incorporated.)</p><h3>Summary</h3><p>UMatcher represents a practical middle ground between traditional template matching and modern object detectors, offering strong adaptability for mobile deployment. The project code is fully open source:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*3X7CYTtLdpGYbyId4e7dmw.png" /><figcaption><a href="https://github.com/aemior/UMatcher">https://github.com/aemior/UMatcher</a></figcaption></figure><p>We hope this project can serve as a valuable reference for your own development work.</p><p>Of course, there is still room for continuous improvement. For example, the current architecture is relatively conservative; integrating modern Transformer-based structures could potentially yield significant performance gains. This solution is offered as a starting point to inspire more engineering-focused, practical approaches.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d45a3d76eca" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>