Instructions to use litert-community/GLiClass-Edge-v3.0-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/GLiClass-Edge-v3.0-LiteRT with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 2,415 Bytes
88c9095 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #!/usr/bin/env bash
# Download first (the four files the app needs):
# hf download litert-community/GLiClass-Edge-v3.0-LiteRT gliclass_edge_v3_s128_fp32.tflite \
# gliclass_edge_v3_s256_fp32.tflite host_assets/tok_embeddings_fp16.bin host_assets/tokenizer.json \
# --local-dir "$HOME/Downloads/GLiClass-Edge-v3.0-LiteRT"
# Usage: ./scripts/install_to_device.sh [dir-with-downloaded-HF-repo]
# The directory holds the two *_fp32.tflite graphs and host_assets/ (tok_embeddings_fp16.bin,
# tokenizer.json). A directory without host_assets/ is read flat (all four files side by side).
# Set ANDROID_SERIAL to select a device when more than one is connected.
set -euo pipefail
if [[ $# -gt 1 ]]; then
printf 'Usage: %s [dir-with-downloaded-HF-repo]\n' "$0" >&2
exit 2
fi
SOURCE_DIR="${1:-$HOME/Downloads/GLiClass-Edge-v3.0-LiteRT}"
PACKAGE=com.gliclass
TEMP_DIR=/data/local/tmp/gliclass
FILES=(
gliclass_edge_v3_s128_fp32.tflite
gliclass_edge_v3_s256_fp32.tflite
tok_embeddings_fp16.bin
tokenizer.json
)
source_file() {
case "$1" in
*.tflite) printf '%s/%s\n' "$SOURCE_DIR" "$1" ;;
*)
if [[ -d "$SOURCE_DIR/host_assets" ]]; then
printf '%s/host_assets/%s\n' "$SOURCE_DIR" "$1"
else
printf '%s/%s\n' "$SOURCE_DIR" "$1"
fi
;;
esac
}
# Check every source before the first device command to avoid a partial installation.
for name in "${FILES[@]}"; do
source="$(source_file "$name")"
if [[ ! -f "$source" ]]; then
printf 'Missing source file: %s\n' "$source" >&2
exit 1
fi
done
table="$(source_file tok_embeddings_fp16.bin)"
if [[ "$(wc -c < "$table" | tr -d ' ')" != 38684160 ]]; then
printf 'tok_embeddings_fp16.bin is not the [50370,384] float16 table: %s\n' "$table" >&2
exit 1
fi
pending=''
cleanup() {
if [[ -n "$pending" ]]; then
adb shell rm -f "$pending"
fi
}
trap cleanup EXIT
adb shell mkdir -p "$TEMP_DIR"
adb shell run-as "$PACKAGE" mkdir -p files
for name in "${FILES[@]}"; do
pending="$TEMP_DIR/$$-$name"
printf 'Staging %s\n' "$name"
adb push "$(source_file "$name")" "$pending"
adb shell run-as "$PACKAGE" cp "$pending" "files/$name"
adb shell rm "$pending"
pending=''
done
adb shell rmdir "$TEMP_DIR"
adb shell run-as "$PACKAGE" ls -la files/
printf 'Assets installed. Launch GLiClass Edge.\n'
|