Spaces:
Running
Running
Commit ·
fc19dcf
1
Parent(s): f77a308
update: export from starry-refactor 2026-02-20 14:58
Browse files- 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 |
-
|
|
|
|
| 157 |
if [ -n "$model_file" ]; then
|
| 158 |
hf_download "starry-dist" "$model_path/$model_file"
|
| 159 |
fi
|
| 160 |
-
|
|
|
|
| 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/^
|
| 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
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
eval config_path=\$$config_var
|
| 179 |
if [ -n "$config_path" ]; then
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 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 |
-
|
| 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
|