DEV Community

Cover image for Why I Ditched Cloud APIs for Edge ML: Building a 100% Offline AI Photo Studio
Swawon Mondal
Swawon Mondal

Posted on

Why I Ditched Cloud APIs for Edge ML: Building a 100% Offline AI Photo Studio

The standard playbook for building AI applications today is almost always the same: wrap a cloud API, charge a subscription, and send user data to a remote server.

When I set out to build an AI-powered image processing utility, I wanted to do the exact opposite. I wanted to see if I could build a professional-grade tool that handles heavy machine learning tasks entirely on-device, with zero data transmission liabilities.

The result is ProEnhanceX, an Android photo studio built entirely around privacy-first edge computing. Here is a look at the architecture I used to pull it off, and the challenges of moving ML pipelines away from the cloud and directly into the users' hands.

The Architecture: ONNX and Native FFI

To eliminate the need for cloud servers, the core pipeline executes all machine learning models locally using an ONNX runtime environment.

Running inference on mobile hardware is tricky. You are fighting thermal throttling, battery drain, and memory limits. To keep the application responsive and ensure the image filters process instantly, I couldn't rely on standard high-level implementations.

Instead, I implemented native FFI (Foreign Function Interface) library bindings. Working through the Dart package API for the ONNX runtime required strict handling of data types and memory management to bridge the native C++ execution seamlessly. It took significant tuning, but offloading the heavy lifting via FFI allowed the UI to remain perfectly smooth while complex ML tasks run in the background.

Training on Kaggle and Mobile Quantization

You do not need a massive server farm to build effective ML tools. For several of the custom filters, I utilized Kaggle's free GPU environments to train and fine-tune the architectures. Kaggle notebooks provided a highly accessible sandbox to iterate on model weights and test different computer vision approaches without burning through expensive cloud compute credits.

However, a model trained on a desktop-class GPU cannot simply be dropped into an Android app. The raw models were far too large and compute-heavy. To make them viable for edge deployment, I had to aggressively quantize them before export. By converting the neural network weights from standard 32-bit floating-point (FP32) down to smaller precision formats like INT8, I drastically reduced the memory footprint and accelerated inference time. Exporting these quantized models to the ONNX format was the exact bridge needed to move them from a Kaggle notebook directly onto the user's phone.

The Reality of Edge ML Optimization

Building for the edge is a balancing act between speed and quality, and it doesn't always go smoothly.

A great example from this project was my implementation of a guided image filter. I spent a significant amount of time writing what I thought was a highly optimized, leaner algorithm specifically for mobile constraints. It ran faster, but when I finally ran comparative evaluations, the algorithmic changes had noticeably degraded the output quality compared to my prior baseline.

I had to completely scrap the "optimized" version, revert to the original pipeline, and find performance gains elsewhere. It was a harsh reminder that when you are building photo enhancement tools, you cannot sacrifice output fidelity just to shave a few milliseconds off the execution time.

Try It Out

If you are interested in mobile ML, privacy-first apps, or just need a solid photo editor, I would love for you to check it out.

You can download ProEnhanceX on the Google Play Store here:
ProEnhanceX on Google Play

I am currently monitoring how the localized models handle edge cases across different Android hardware profiles. If you have any questions about implementing local ONNX runtimes, quantizing models for mobile, or dealing with native FFI bindings, let me know in the comments!

Top comments (0)