Repository navigation
On-device text-to-image and "More like this" search (#939, #66): working implementation on a fork #2283
Replies: 2 comments 1 reply
|
Thanks for taking the time to work on this. As you know, this repo does not accept PRs, and that means external work in general. Especially code from AI. Out of curiosity, how's internationalisation? In other words, is searching for images using non-English text supported by that kind of models? |
|
Yes—there is now an optional multilingual SigLIP2 image/text model. I tested searches in Japanese (森の川), Hindi (जंगल में नदी), German (ein wald mit einem bach), and English (purple flowers) on a Kindle Fire; the corresponding forest/river and flower photos appeared among the best matches. This is an on-device model downloaded only when selected (570 MiB); language quality can vary. For anyone who wants to try the fork rather than build it, I published the exact signed, non-debuggable arm64 APK tested on that Fire: https://github.com/jasontitus/aves/releases/tag/smart-search-preview-1.15.4-1 . It installs separately as deckers.thibault.aves.preview and does not replace upstream Aves. The Fire scan completed with 1,435 items indexed and 3 unreadable items. A 64-bit device with at least 3.5 GB RAM is required. APK SHA-256: 82af82a22ea0ee40d755597b498267ab399c77f5b70514b4f06d40c97cd88090. This is an independent preview on my fork, not an upstream release. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I know the README says code PRs aren't accepted, so I'm posting this here instead of opening one. It's a working implementation of the text-to-image and similar-image search requested in #939 and #66, available as a branch on my fork in case any of it is useful:
jasontitus/aves@feature/smart-search, 2 commits on top of currentdevelop, merges cleanlydevelop...jasontitus:feature/smart-searchIn #66 you said shipping a model as part of Aves is out. Here, no model is in the APK: models are downloaded on demand, only after the user enables the feature. The ONNX Runtime library, though, is bundled (+23–33 MB), which is why open question 1 below suggests restricting it to some flavors or a separate APK.
Tested on real devices, 64-bit and 32-bit:
I'd be glad to reshape any of this (split it, move it behind a flavor, drop parts) if you're interested, and equally fine if it doesn't fit your plans.
Adds optional on-device semantic search to Aves:
Everything runs on the device. The only network traffic is a one-time model download, which the user explicitly starts. Photos, videos and queries are never sent anywhere.
The feature is off by default. It is designed for low- and mid-range devices with 2–4 GB of RAM; Amazon Fire tablets were the reference target.
How it works
/regex/,"exact",-neg,YEAR=…) or a file-name-like query that matches item titles (IMG_2041); filtering by title stays available from the query suggestion chip. Also: recent smart searches, a ranked results page (fixed order, no date headers), the viewer "More like this" action (also available as a quick action), and a settings section (enable, model, Wi-Fi only, charging only, index status, delete)Models, licenses and download
laion2b_s34b_b79kebc8231d…) and embeds each file's SHA-256 and size. Files are verified while being copied from the DownloadManager destination into privateno_backupstorage, and are only used once verified. The model card lists the sources, the modifications and the licenses.scripts/smart_search/convert.pyreproduces the files: OpenCLIP → ONNX (opset 18) → dynamic int8 per-channel → ORT. With the listed versions, the ViT-B/32 conversion is byte-identical across runs.terms.md/terms.txt) and the README permissions table mention the model download.Quality
Flickr30k 1k test split, text → image retrieval over 5,000 captions. Images are first downscaled to thumbnails, as the app does.
Naive int8 quantization of the ViT-B/32 text encoder gives R@1 0.41. One projection layer with activation outliers is kept in fp32.
APK size (libre flavor, release, split per ABI)
developAlmost all of the growth is the ONNX Runtime native library. Models are never bundled. See open question 1.
Performance
Amazon Fire Max 11 (MediaTek MT8188, 4 GB), release or profile build:
The PSS "after" figure includes GPU texture memory for thumbnail grids, which grows the same way when scrolling the collection without smart search. The encoders themselves are released after idle; no model file stays mapped.
Amazon Fire Max 11, 32-bit (armeabi-v7a) app, profile build, Standard model (Best quality needs a 64-bit device). The 32-bit ONNX Runtime is much slower than on 64-bit, but it works end to end:
Samsung Galaxy A35 5G (Exynos 1380, 6 GB, Android 16), profile build, 108 items (71 videos, including 14 empty files):
2 GB RAM emulator (arm64, Android 11, profile build):
Encoders load lazily. They are released after 20 s (image) or 60 s (text) of idle time, and on
TRIM_MEMORY_RUNNING_LOWand above. Indexing runs with 1–2 threads, spinning is disabled, and the scheduler checks battery and thermal state between batches.Testing
Automated
test/model/smart_search_test.dart, all 90 passing. They cover:IMG_2041filter), including file names inside calendar day stacks, and no search from the bin.ClipTokenizerTest, 260 golden strings against the reference Python tokenizer, including ftfy and HTML-entity cases;VectorStoreTest, 16 tests covering CRC corruption, torn writes, tombstones, compaction, churn, generation guards and statistics.flutter analyzeis clean.On device and emulator. All of the following passed:
Issues found by the device testing, all fixed in this branch:
Open questions
ORT in which flavors / F-Droid. ORT Android is an MIT-licensed prebuilt AAR from Maven Central. F-Droid builds from source and may not accept the prebuilt native library. Options:
playandizzyflavors (the code is already isolated behind the channel, so a no-op handler is easy);Happy to implement whichever you prefer.
Model hosting ownership. The files are on a Hugging Face repo that I control. They're pinned by commit and hash, so they can't change under the app, but you may prefer a repo you own: an HF org or GitHub Releases on
deckerst/aves_extra, for example. The conversion script is in this branch, so moving them is a copy plus a URL/commit change inModelCatalog.kt.Promo on the search page. A dismissible "Find photos by describing them" tile is shown until dismissed or enabled. Keep it, or rely on settings only?
Translations. Only
app_en.arbhas the new strings (the Weblate workflow is left to you).CI. Should the gradle unit tests (
:app:testLibreDebugUnitTest) be added to the workflow? They needtestOptions.unitTests.isReturnDefaultValues = trueforandroid.util.Log.Test data size. The tokenizer test adds the 1.4 MB CLIP BPE vocabulary (MIT, license file alongside) under
android/app/src/test/resources. It could be fetched at test time instead, if you'd rather not have the binary in the repo.🤖 Generated with Claude Code
All reactions