k-l-lambda commited on
Commit
fc19dcf
·
1 Parent(s): f77a308

update: export from starry-refactor 2026-02-20 14:58

Browse files
Files changed (1) hide show
  1. docker-entrypoint.sh +23 -24
docker-entrypoint.sh CHANGED
@@ -153,16 +153,18 @@ export PREDICTOR_BRACKETS="${PREDICTOR_BRACKETS:-tcp://127.0.0.1:12028}"
153
 
154
  state_yaml="$MODELS_BASE/starry-dist/$model_path/.state.yaml"
155
  if [ -f "$state_yaml" ]; then
156
- model_file=$(sed -n 's/^file: *//p' "$state_yaml" | head -1)
 
157
  if [ -n "$model_file" ]; then
158
  hf_download "starry-dist" "$model_path/$model_file"
159
  fi
160
- sed -n '/^subs:/,/^[a-z]/{ /^ - /p }' "$state_yaml" | sed 's/^ *- *//' | while read -r sub; do
 
161
  if [ -n "$sub" ]; then
162
  hf_download "starry-dist" "$model_path/$sub/.state.yaml"
163
  sub_state="$MODELS_BASE/starry-dist/$model_path/$sub/.state.yaml"
164
  if [ -f "$sub_state" ]; then
165
- sub_file=$(sed -n 's/^file: *//p' "$sub_state" | head -1)
166
  if [ -n "$sub_file" ]; then
167
  hf_download "starry-dist" "$model_path/$sub/$sub_file"
168
  fi
@@ -173,30 +175,27 @@ export PREDICTOR_BRACKETS="${PREDICTOR_BRACKETS:-tcp://127.0.0.1:12028}"
173
  fi
174
  done
175
 
176
- # Download OCR/TF models (ocr-dist)
177
- for config_var in LOC_MODEL_PATH OCR_CONFIG BRACKETS_CONFIG; do
 
 
 
 
 
178
  eval config_path=\$$config_var
179
  if [ -n "$config_path" ]; then
180
- if echo "$config_path" | grep -q '\.yaml$\|\.yml$'; then
181
- hf_download "ocr-dist" "$config_path"
182
- config_file="$MODELS_BASE/ocr-dist/$config_path"
183
- if [ -f "$config_file" ]; then
184
- sed -n 's/^ *model_path: *//p' "$config_file" | while read -r mpath; do
185
- if [ -n "$mpath" ]; then
186
- _dir=$(dirname "$config_path")
187
- hf_download "ocr-dist" "$_dir/$mpath"
188
- fi
189
- done
190
- fi
191
- else
192
- hf_download "ocr-dist" "$config_path/.state.yaml"
193
- state_yaml="$MODELS_BASE/ocr-dist/$config_path/.state.yaml"
194
- if [ -f "$state_yaml" ]; then
195
- model_file=$(sed -n 's/^file: *//p' "$state_yaml" | head -1)
196
- if [ -n "$model_file" ]; then
197
- hf_download "ocr-dist" "$config_path/$model_file"
198
  fi
199
- fi
200
  fi
201
  fi
202
  done
 
153
 
154
  state_yaml="$MODELS_BASE/starry-dist/$model_path/.state.yaml"
155
  if [ -f "$state_yaml" ]; then
156
+ # Model weight file is in "best:" field (not "file:")
157
+ model_file=$(sed -n 's/^best: *//p' "$state_yaml" | head -1)
158
  if [ -n "$model_file" ]; then
159
  hf_download "starry-dist" "$model_path/$model_file"
160
  fi
161
+ # Sub-models listed under "subs:" (skip commented lines starting with #)
162
+ sed -n '/^subs:/,/^[a-z]/{ /^[^#]*- /p }' "$state_yaml" | sed 's/^ *- *//' | while read -r sub; do
163
  if [ -n "$sub" ]; then
164
  hf_download "starry-dist" "$model_path/$sub/.state.yaml"
165
  sub_state="$MODELS_BASE/starry-dist/$model_path/$sub/.state.yaml"
166
  if [ -f "$sub_state" ]; then
167
+ sub_file=$(sed -n 's/^best: *//p' "$sub_state" | head -1)
168
  if [ -n "$sub_file" ]; then
169
  hf_download "starry-dist" "$model_path/$sub/$sub_file"
170
  fi
 
175
  fi
176
  done
177
 
178
+ # Download LOC model (a single file, not a directory)
179
+ if [ -n "$LOC_MODEL_PATH" ]; then
180
+ hf_download "ocr-dist" "$LOC_MODEL_PATH"
181
+ fi
182
+
183
+ # Download OCR/TF config yamls and all referenced files
184
+ for config_var in OCR_CONFIG BRACKETS_CONFIG; do
185
  eval config_path=\$$config_var
186
  if [ -n "$config_path" ]; then
187
+ hf_download "ocr-dist" "$config_path"
188
+ config_file="$MODELS_BASE/ocr-dist/$config_path"
189
+ if [ -f "$config_file" ]; then
190
+ _dir=$(dirname "$config_path")
191
+ # Download all *_path values referenced in the yaml
192
+ grep '_path:' "$config_file" | sed 's/^[^:]*: *//' | while read -r ref_path; do
193
+ if [ -n "$ref_path" ]; then
194
+ # Resolve ./ relative paths
195
+ ref_path=$(echo "$ref_path" | sed 's|^\./||')
196
+ hf_download "ocr-dist" "${_dir:+$_dir/}$ref_path"
 
 
 
 
 
 
 
 
197
  fi
198
+ done
199
  fi
200
  fi
201
  done