Biphoo News

collapse
Home / Daily News Analysis / Local AI on NPUs: Building a zero-cloud photo deduplicator with OpenCLIP

Local AI on NPUs: Building a zero-cloud photo deduplicator with OpenCLIP

Oct 14, 2026  Twila Rosenbaum  53 views
Local AI on NPUs: Building a zero-cloud photo deduplicator with OpenCLIP

Headline

Local AI on NPUs: Building a zero-cloud photo deduplicator with OpenCLIP

Key Facts

  • Modern laptops include neural processing units that can run small AI models at single-digit wattage.
  • A zero-cloud photo deduplicator uses OpenCLIP image embeddings to compare visual similarity without uploading files.
  • OpenVINO converts PyTorch models into an Intermediate Representation that can execute on CPU, GPU, or NPU.
  • Batched NPU inference with a throughput hint reached over 92 images per second at roughly 22.7 watts.
  • Cosine similarity above 0.92 groups near-duplicate photos, and union-find handles transitive clusters.

Why heavy media work belongs on local silicon

Every new laptop is now marketed as an AI PC because it includes a neural processing unit. But beyond chatting with small local language models, what practical work can this silicon actually do? A common household problem provides a clear answer: organizing and deduplicating large photo archives. A collection of scanned family photos can easily reach a hundred gigabytes, and uploading that much media to a cloud API for a simple deduplication task is unreasonable. The compute needs to move to the data, and that means using the idle NPU inside a consumer laptop.

The issue is not only privacy. Data gravity is the physical bottleneck. Archiving thousands of pre-digital photos and massive video files is common, and those archives can span terabytes. Cloud uploads become a bandwidth nightmare. The default architecture of the AI boom, which sends every inference task to a centralized cloud API, is colliding with hard physical limits. The electrical grid cannot support the current pace of hyperscale build-outs. Industry projections show US utility capacity falling short of data center power demand by over 100 gigawatts by 2030. Regulators are stepping in to throttle growth. In September 2026, Virginia, the densest data center region in the world, signed Executive Order 22, restricting state assistance for new hyperscale deployments over 25 megawatts due to grid and water constraints. The cloud’s physical room is running out, which is exactly why compute has to move to the data.

Understanding the edge hardware trade-offs

To understand why local AI architecture is shifting, it helps to look at how modern silicon divides workloads across different classes of hardware.

  • CPU: It handles system logic and file I/O effortlessly, but running continuous neural network math requires brute force. It can peg core usage at 100%, draw 35W or more, and rapidly drain a laptop battery.
  • GPU: Built for massive graphics rendering and high-throughput compute, but highly power-hungry and often reserved for heavy graphics or dedicated model running or training.
  • NPU: Purpose-built for low-power matrix operations on consumer devices. It handles smaller AI workloads at single-digit wattage, often around 6W.

Apple platforms are a special case. Experimental projects show that Apple’s 32-core NPU can run massive 27B models while sipping just 8W of power. While this efficiency is exactly what the industry needs, it remains strictly experimental—the inference speeds are not yet viable for production workloads. High-end AI desktops such as the NVIDIA GB10 also do not have NPUs. Instead, they rely on massive GPUs packed with thousands of Tensor Cores and unified memory, with combined consumption sometimes exceeding 160W.

Building a semantic deduplication pipeline with OpenCLIP

For this project, the focus is image deduplication and making an idle NPU speed up the pipeline. Semantic deduplication works by comparing the distance between image embeddings—high-dimensional digital representations of pictures. Generating these embeddings is the heavy lifting done by the AI model. Before anything reaches the model, each photo goes through a pinned preprocessing step: resize the short side to 256 pixels, center-crop to 224, and then normalize with published constants. Applying the exact same crop and transform to every image on every run is what keeps comparisons mathematically stable.

The foundation for this approach was laid in March 2021, when OpenAI introduced Contrastive Language-Image Pre-training, or CLIP. Prior to CLIP, computer vision models were largely rigid classifiers trained on fixed datasets like ImageNet, capable of recognizing only a pre-defined set of categories. OpenAI changed this by training a dual-encoder architecture on 400 million image-text pairs scraped from the web. By training an image encoder and text encoder simultaneously to pull matching pairs together in a shared vector space and push mismatched pairs apart, CLIP learned generalized visual concepts rather than narrow labels.

When OpenAI released CLIP, it published pre-trained weights for several architectures, including ResNet variants and a then-novel Vision Transformer. Over the last few years, the open-source community, notably the OpenCLIP project, and other AI labs have scaled this architecture massively, releasing much heavier variants like ViT-L, ViT-H, and ViT-g.

The implementation chosen for this pipeline is OpenCLIP with OpenAI’s original ViT-B-32-quickgelu model. It sits at the sweet spot for edge hardware: small enough to compile directly into NPU memory without thrashing the host system, yet sophisticated enough to recognize that two photos taken from slightly different angles share the same subject. To generate embeddings locally, the stack relies on Python 3.14, PyTorch, OpenCLIP ViT-B/32, and ImageMagick for parallel preprocessing. When it comes to model compilers, the architecture gets interesting because each vendor has its own implementation. On the Intel platform, OpenVINO converts the PyTorch encoder into an optimized Intermediate Representation capable of running on any of the machine’s accelerators: CPU, GPU, or NPU.

The installation steps include creating a Python 3.14 virtual environment, installing PyTorch CPU wheels, OpenCLIP, OpenVINO, ONNX, NumPy, Pillow, and ImageMagick. The ONNX toolchain exports the encoder to ONNX, which OpenVINO then converts into an IR. The host side needs only CPU wheels for PyTorch, because the heavy inference runs on the NPU after compilation.

Benchmarking the NPU against the CPU with OpenVINO

Running the initial PyTorch script on the CPU was highly taxing. Baseline throughput hovered around 35 milliseconds per photo, and power consumption hit 47W. While that might sound fast for a single image, processing a massive archive kept the CPU pegged at nearly 100% utilization. The laptop fans spun up immediately, and system monitoring tools showed a power draw exceeding 46 watts just to crunch through the matrix math. It was a brute-force approach that monopolized the machine and rapidly drained the battery.

To fix this, the model was exported to OpenVINO’s Intermediate Representation format and the workload was routed through Intel’s Level-Zero driver API directly into the NPU. One gotcha is worth knowing: the ONNX exporter bakes the batch size into the graph’s internal reshape constants, so the script exports one IR per batch size and the runtime loads whichever matches the batch parameter.

The first pass used a naive, synchronous loop—sending one image down to the silicon at a time. This yielded a modest 1.5x speedup and an impressive 2x lower power consumption. The bottleneck was not the NPU itself but the host-device dispatch overhead. The NPU finished the tensor math in milliseconds and then sat idle, waiting for Python to hand it the next image. The Level-Zero driver compiles a hardware blob on the first execution, which causes a brief delay, but subsequent runs initialize instantly. Once compiled, the encoder runs in fp16, which halves its memory traffic on the silicon.

The synchronous NPU loop improved throughput to about 25 milliseconds per image but left the accelerator idle between dispatch calls. Power consumption decreased to 27W. To unlock the silicon’s true potential, the script was restructured to use batched inference and OpenVINO’s THROUGHPUT performance hint. By feeding the NPU batches of 16 images simultaneously, it saturated its execution units and eliminated the dispatch bottleneck. Per-photo inference time dropped from about 36 milliseconds on the CPU to about 13 milliseconds on the NPU, and end-to-end throughput climbed from roughly 28 photos per second in a serial, single-image pass to over 92—a 3x win. But raw speed was not the real victory. Efficiency was. The NPU silently chewed through thousands of images in the background, drawing a mere 22W, allowing processing of a massive media archive on battery power without triggering the fans.

Filtering the noise with cosine similarity

The actual goal is detecting duplicate photos. For this step, the assumption is that there are no exact binary duplicate images in the collection. The script reads the 512-dimensional embeddings generated by OpenCLIP and normalizes each to unit length, which turns cosine similarity into a plain dot product—one matrix multiply across the whole archive. By calculating the similarity between these vectors, essentially measuring how aligned two points are in mathematical space, the script gets a numerical score showing how visually similar two photos are.

Photos that clear the similarity threshold, set at 0.92, get grouped into a duplicate cluster. Because similarity is chained transitively through union-find, a burst of five shots where each neighbor just barely matches is still pulled into a single cluster. Each cluster’s photos and their embedding sidecars are moved together into a dup_XXXX folder, while unique photos stay put. The scan is non-recursive into subfolders, so re-running the tool on an already-sorted archive is a safe no-op. A dry-run flag identifies the clusters first without moving anything.

The final pass compares the


Source: InfoWorld News


Share:

Your experience on this site will be improved by allowing cookies Cookie Policy