0xZohar commited on
Commit
0926bed
·
verified ·
1 Parent(s): 2bb4b5b

Fix startup hang: 添加模型预下载步骤

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -0
Dockerfile CHANGED
@@ -97,6 +97,28 @@ RUN ls -la $HOME/app/code/ImportLDraw/__init__.py || \
97
  RUN pip install --no-cache-dir --upgrade pip && \
98
  pip install --no-cache-dir -r requirements.txt
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  # 创建启动脚本(先启动 Xvfb,再运行应用)
101
  RUN echo '#!/bin/bash\n\
102
  echo "🖥️ 启动虚拟显示服务器 Xvfb..."\n\
 
97
  RUN pip install --no-cache-dir --upgrade pip && \
98
  pip install --no-cache-dir -r requirements.txt
99
 
100
+ # 预下载所有模型权重(避免运行时下载卡住)
101
+ RUN echo "📥 Pre-downloading model weights during build..." && \
102
+ python -c "\
103
+ import os; \
104
+ os.makedirs('/data/.huggingface', exist_ok=True); \
105
+ os.environ['HF_HOME'] = '/data/.huggingface'; \
106
+ os.environ['HF_HUB_CACHE'] = '/data/.huggingface/hub'; \
107
+ os.environ['TRANSFORMERS_CACHE'] = '/data/.huggingface/transformers'; \
108
+ from huggingface_hub import hf_hub_download; \
109
+ print('Downloading shape_gpt.safetensors (7.17 GB)...'); \
110
+ hf_hub_download(repo_id='0xZohar/object-assembler-models', filename='shape_gpt.safetensors', cache_dir='/data/.huggingface'); \
111
+ print('Downloading shape_tokenizer.safetensors (1.09 GB)...'); \
112
+ hf_hub_download(repo_id='0xZohar/object-assembler-models', filename='shape_tokenizer.safetensors', cache_dir='/data/.huggingface'); \
113
+ print('Downloading fine-tuned adapter (1.68 GB)...'); \
114
+ hf_hub_download(repo_id='0xZohar/object-assembler-models', filename='save_shape_cars_whole_p_rot_scratch_4mask_randp.safetensors', cache_dir='/data/.huggingface'); \
115
+ print('Downloading CLIP model (~600 MB)...'); \
116
+ from transformers import CLIPModel, CLIPProcessor; \
117
+ CLIPModel.from_pretrained('openai/clip-vit-base-patch32', cache_dir='/data/.huggingface'); \
118
+ CLIPProcessor.from_pretrained('openai/clip-vit-base-patch32', cache_dir='/data/.huggingface'); \
119
+ print('✅ All models pre-downloaded')" && \
120
+ echo "✅ Model weights cached in /data/.huggingface"
121
+
122
  # 创建启动脚本(先启动 Xvfb,再运行应用)
123
  RUN echo '#!/bin/bash\n\
124
  echo "🖥️ 启动虚拟显示服务器 Xvfb..."\n\