Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +19 -21
Dockerfile
CHANGED
|
@@ -1,18 +1,11 @@
|
|
| 1 |
-
FROM python:3.10
|
| 2 |
|
| 3 |
# 安装系统依赖
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
build-essential \
|
| 6 |
-
|
| 7 |
-
git \
|
| 8 |
-
file \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
# 安装 Git LFS
|
| 12 |
-
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
|
| 13 |
-
apt-get install -y git-lfs && \
|
| 14 |
-
git lfs install
|
| 15 |
-
|
| 16 |
# 安装 PyTorch
|
| 17 |
RUN pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cpu
|
| 18 |
|
|
@@ -24,15 +17,20 @@ RUN pip install -r requirements.txt
|
|
| 24 |
COPY . /app
|
| 25 |
WORKDIR /app
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
RUN
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
|
| 3 |
# 安装系统依赖
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
build-essential \
|
| 6 |
+
wget \
|
|
|
|
|
|
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# 安装 PyTorch
|
| 10 |
RUN pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cpu
|
| 11 |
|
|
|
|
| 17 |
COPY . /app
|
| 18 |
WORKDIR /app
|
| 19 |
|
| 20 |
+
# 创建 checkpoint 目录
|
| 21 |
+
RUN mkdir -p checkpoint
|
| 22 |
+
|
| 23 |
+
# 下载模型文件的脚本
|
| 24 |
+
RUN echo '#!/bin/sh\n\
|
| 25 |
+
if [ ! -f "checkpoint/final_model_K_30.pth" ]; then\n\
|
| 26 |
+
echo "下载模型文件..."\n\
|
| 27 |
+
wget -O checkpoint/final_model_K_30.pth \\\n\
|
| 28 |
+
"https://huggingface.co/spaces/Hanxiaofeng123/Deepcube/blob/main/checkpoint/final_model_K_30.pth"\n\
|
| 29 |
+
else\n\
|
| 30 |
+
echo "模型文件已存在"\n\
|
| 31 |
+
ls -lh checkpoint/final_model_K_30.pth\n\
|
| 32 |
+
fi' > /download_model.sh && \
|
| 33 |
+
chmod +x /download_model.sh
|
| 34 |
+
|
| 35 |
+
# 入口(先下载模型,再运行应用)
|
| 36 |
+
CMD ["sh", "-c", "/download_model.sh && python app.py"]
|