|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +model_dir="/Users/cxt/model/llm/mobileVLM/MobileVLM-1.7B_processed" |
| 4 | +projector_name="mmproj-model-f16.gguf" |
| 5 | +llama_name="ggml-model-q4_k.gguf" |
| 6 | +img_dir="/Users/cxt/model/llm" |
| 7 | +img_name="demo.jpg" |
| 8 | +prompt="A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\nWho is the author of this book? \nAnswer the question using a single word or phrase. ASSISTANT:" |
| 9 | +# img_name="cat.jpeg" |
| 10 | +# prompt="A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\nWhat is in the image? ASSISTANT:" |
| 11 | + |
| 12 | +program_dir="build_64/bin" |
| 13 | +binName="minicpmv-cli" |
| 14 | +n_threads=4 |
| 15 | + |
| 16 | + |
| 17 | +deviceDir="/data/local/tmp" |
| 18 | +saveDir="output" |
| 19 | +if [ ! -d ${saveDir} ]; then |
| 20 | + mkdir ${saveDir} |
| 21 | +fi |
| 22 | + |
| 23 | + |
| 24 | +function android_run() { |
| 25 | + # # copy resource into device |
| 26 | + # adb push ${model_dir}/${projector_name} ${deviceDir}/${projector_name} |
| 27 | + # adb push ${model_dir}/${llama_name} ${deviceDir}/${llama_name} |
| 28 | + adb push ${img_dir}/${img_name} ${deviceDir}/${img_name} |
| 29 | + # copy program into device |
| 30 | + adb push ${program_dir}/${binName} ${deviceDir}/${binName} |
| 31 | + adb shell "chmod 0777 ${deviceDir}/${binName}" |
| 32 | + |
| 33 | + # run |
| 34 | + adb shell "echo cd ${deviceDir} ${deviceDir}/${binName} \ |
| 35 | + -m ${deviceDir}/${llama_name} \ |
| 36 | + --mmproj ${deviceDir}/${projector_name} \ |
| 37 | + -t ${n_threads} \ |
| 38 | + --image ${deviceDir}/${img_name} \ |
| 39 | + -p \"${prompt}\" \ |
| 40 | + > ${deviceDir}/${modelName}_${projector_name}_${n_threads}_${img_name}.txt" |
| 41 | + adb shell "cd ${deviceDir}; pwd; ${deviceDir}/${binName} \ |
| 42 | + -m ${deviceDir}/${llama_name} \ |
| 43 | + --mmproj ${deviceDir}/${projector_name} \ |
| 44 | + -t ${n_threads} \ |
| 45 | + --image ${deviceDir}/${img_name} \ |
| 46 | + -p \"${prompt}\" \ |
| 47 | + >> ${deviceDir}/${modelName}_${projector_name}_${n_threads}_${img_name}.txt 2>&1" |
| 48 | + adb pull ${deviceDir}/${modelName}_${projector_name}_${n_threads}_${img_name}.txt ${saveDir} |
| 49 | +} |
| 50 | + |
| 51 | +android_run |
| 52 | + |
| 53 | +echo "android_run is Done!" |
0 commit comments