adb_run.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. model_dir="/Users/cxt/model/llm/mobileVLM/MobileVLM-1.7B_processed"
  3. projector_name="mmproj-model-f16.gguf"
  4. llama_name="ggml-model-q4_k.gguf"
  5. img_dir="/Users/cxt/model/llm"
  6. img_name="demo.jpg"
  7. 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:"
  8. # img_name="cat.jpeg"
  9. # 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:"
  10. program_dir="build_64/bin"
  11. binName="llama-mtmd-cli"
  12. n_threads=4
  13. deviceDir="/data/local/tmp"
  14. saveDir="output"
  15. if [ ! -d ${saveDir} ]; then
  16. mkdir ${saveDir}
  17. fi
  18. function android_run() {
  19. # # copy resource into device
  20. # adb push ${model_dir}/${projector_name} ${deviceDir}/${projector_name}
  21. # adb push ${model_dir}/${llama_name} ${deviceDir}/${llama_name}
  22. adb push ${img_dir}/${img_name} ${deviceDir}/${img_name}
  23. # copy program into device
  24. adb push ${program_dir}/${binName} ${deviceDir}/${binName}
  25. adb shell "chmod 0777 ${deviceDir}/${binName}"
  26. # run
  27. adb shell "echo cd ${deviceDir} ${deviceDir}/${binName} \
  28. -m ${deviceDir}/${llama_name} \
  29. --mmproj ${deviceDir}/${projector_name} \
  30. -t ${n_threads} \
  31. --image ${deviceDir}/${img_name} \
  32. -p \"${prompt}\" \
  33. > ${deviceDir}/${modelName}_${projector_name}_${n_threads}_${img_name}.txt"
  34. adb shell "cd ${deviceDir}; pwd; ${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 2>&1"
  41. adb pull ${deviceDir}/${modelName}_${projector_name}_${n_threads}_${img_name}.txt ${saveDir}
  42. }
  43. android_run
  44. echo "android_run is Done!"