File size: 1,161 Bytes
d13981b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Normalize ModelScope --local_dir downloads for HuggingFace transformers loading.
# Usage: bash scripts/prepare_local_models.sh models/llava-0.5b-ov models/llava-7b-ov
set -euo pipefail

if [[ $# -lt 1 ]]; then
  echo "Usage: $0 <model_dir> [model_dir ...]" >&2
  exit 1
fi

for raw in "$@"; do
  dir="$(readlink -f "${raw}")"
  if [[ ! -d "${dir}" ]]; then
    echo "ERROR: not a directory: ${raw}" >&2
    exit 1
  fi

  if [[ -d "${dir}/onnx" ]]; then
    echo "Removing unused onnx/: ${dir}/onnx"
    rm -rf "${dir}/onnx"
  fi

  if [[ ! -f "${dir}/config.json" ]]; then
    echo "ERROR: missing config.json in ${dir}" >&2
    exit 1
  fi

  if compgen -G "${dir}/model.safetensors" > /dev/null || compgen -G "${dir}/model-*.safetensors" > /dev/null; then
    ls -lh "${dir}"/model*.safetensors 2>/dev/null | head -3
    echo "OK: ${dir}"
  else
    echo "ERROR: no model.safetensors in ${dir}" >&2
    exit 1
  fi
done

echo "Done. Put the local student and teacher paths directly in a complete YAML"
echo "recipe under model.pretrained_model_path and model.teacher_model_path, then"
echo "launch main.py with --config <recipe.yaml>."