{"id":20207110,"url":"https://github.com/greyovo/clip-android-demo","last_synced_at":"2025-06-13T22:34:38.342Z","repository":{"id":187472478,"uuid":"676963253","full_name":"greyovo/CLIP-android-demo","owner":"greyovo","description":"A demo for running quantized CLIP model (ViT-B/32) on Android.","archived":false,"fork":false,"pushed_at":"2023-10-05T06:25:10.000Z","size":46172,"stargazers_count":42,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T11:13:25.494Z","etag":null,"topics":["android","clip"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/greyovo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-10T12:20:55.000Z","updated_at":"2025-03-03T08:46:05.000Z","dependencies_parsed_at":"2023-10-03T11:39:33.855Z","dependency_job_id":null,"html_url":"https://github.com/greyovo/CLIP-android-demo","commit_stats":null,"previous_names":["greyovo/clip-android-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greyovo%2FCLIP-android-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greyovo%2FCLIP-android-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greyovo%2FCLIP-android-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/greyovo%2FCLIP-android-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/greyovo","download_url":"https://codeload.github.com/greyovo/CLIP-android-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217145,"owners_count":21066633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","clip"],"created_at":"2024-11-14T05:27:29.790Z","updated_at":"2025-04-10T12:33:19.532Z","avatar_url":"https://github.com/greyovo.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLIP-lite-android-demo\n\nA demo for running quantized CLIP model (ViT-B/32) on Android.\n\n## Usage\n\nRun this [jupyter notebook](https://colab.research.google.com/drive/1bW1aMg0er1T4aOcU5pCNYVgmVzBJ4-x4#scrollTo=hPscj2wlZlHb) to get the quantized models:\n\n-  `clip-image-encoder-quant-int8`\n- `clip-text-encoder-quant-int8`\n\nPlace them into `app\\src\\main\\assets`.\n\nThen build and run in your IDE.\n\n\n\n\u003e Note: Do NOT use `PyTorch \u003e 1.13` or it will failed when converting to ONNX format.\n\u003e\n\u003e This project is just for testing, so forgive my casual code. Good luck :)\n\n\n\n## Performance\n\n### Model Size\n\n- Original (Float 32)\n  - ImageEncoder: 335 MB\n  - TextEncoder: 242 MB\n- Quantized (Int8)\n  - ImageEncoder: 91.2 MB\n  - TextEncoder: 61.3 MB\n\n\n\n### Loss\n\nAccuracy compared to original CLIP ViT-B/32 model:\n\n| CIFAR100  | int8  | Original (fp32) | Loss   |\n| --------- | ----- | --------------- | ------ |\n| 2000 pics | 0.825 | 0.871           | -0.046 |\n| 5000 pics | 0.830 | 0.940           | -0.11  |\n\n### Speed\n\nEncode 500 pics in single thread:\n\n\u003e Device: Xiaomi 12S @ Snapdragon 8+ Gen 1\n\n| Resolution | On-disk Size | Model | Time |\n| ---------- | ------------ | ----- | ---- |\n| 400px      | 21KB         | fp32  | ~54s |\n| 400px      | 21KB         | int8  | ~20s |\n| 1000px     | 779KB        | fp32  | ~62s |\n| 1000px     | 779KB        | int8  | ~27s |\n| 4096px     | 1.7MB        | int8  | ~60s |\n| 4096px     | 4MB          | int8  | ~87s |\n\n**Note:**\n\n- The encode time for each image is 35~45ms\n- For images with larger on-disk size, it takes more time to read the image. I have tried ''down-sample'' the large image instead of reading the whole file.\n\n\n\n## Acknowledgement\n\n- [openai/CLIP](https://github.com/openai/CLIP)\n- [ONNX Runtime](https://onnxruntime.ai/)\n- [mazzzystar/Queryable](https://github.com/mazzzystar/Queryable)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreyovo%2Fclip-android-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgreyovo%2Fclip-android-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgreyovo%2Fclip-android-demo/lists"}