Merge branch 'main' of hf.co:spaces/nuu-lab/taiwanese-hakka-whisper-public
Browse files- .gitignore +1 -0
- Dockerfile +56 -0
- app.py +2 -1
- docker-compose.yml +26 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.env
|
Dockerfile
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM ubuntu:22.04 AS stage1
|
2 |
+
|
3 |
+
# 安装 Python 3.10
|
4 |
+
RUN apt-get update && \
|
5 |
+
apt-get install -y python3.10 python3-pip
|
6 |
+
|
7 |
+
# 设置 python 和 pip 的替代版本
|
8 |
+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 && \
|
9 |
+
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
|
10 |
+
|
11 |
+
# 安裝 Python 相關依賴
|
12 |
+
RUN pip install --no-cache-dir pip==22.3.1 && \
|
13 |
+
pip install --no-cache-dir \
|
14 |
+
datasets \
|
15 |
+
"huggingface-hub>=0.19" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
|
16 |
+
|
17 |
+
# 安裝系統級別的依賴
|
18 |
+
RUN apt-get install -y \
|
19 |
+
git \
|
20 |
+
git-lfs \
|
21 |
+
ffmpeg \
|
22 |
+
libsm6 \
|
23 |
+
libxext6 \
|
24 |
+
cmake \
|
25 |
+
libgl1-mesa-glx \
|
26 |
+
&& git lfs install \
|
27 |
+
&& rm -rf /var/lib/apt/lists/*
|
28 |
+
|
29 |
+
FROM stage1 AS stage2
|
30 |
+
|
31 |
+
# 修改 apt-get 以使用 fakeroot,並創建非 root 用戶
|
32 |
+
RUN apt-get update && apt-get install -y fakeroot && \
|
33 |
+
mv /usr/bin/apt-get /usr/bin/.apt-get && \
|
34 |
+
echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \
|
35 |
+
chmod +x /usr/bin/apt-get && \
|
36 |
+
rm -rf /var/lib/apt/lists/* && \
|
37 |
+
useradd -m -u 1000 user
|
38 |
+
|
39 |
+
# 安裝 requirements.txt 中的依賴
|
40 |
+
COPY requirements.txt requirements.txt
|
41 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
42 |
+
|
43 |
+
FROM stage2 AS stage3
|
44 |
+
|
45 |
+
# 安裝 Gradio 及相關依賴
|
46 |
+
RUN pip install --no-cache-dir \
|
47 |
+
gradio[oauth]==4.27.0 \
|
48 |
+
"uvicorn>=0.14.0"
|
49 |
+
|
50 |
+
FROM stage3 AS stage4
|
51 |
+
|
52 |
+
WORKDIR /home/user/app
|
53 |
+
|
54 |
+
COPY --chown=1000:1000 . /home/user/app
|
55 |
+
|
56 |
+
ENTRYPOINT ["python", "app.py"]
|
app.py
CHANGED
@@ -7,6 +7,7 @@ from git.exc import GitCommandError
|
|
7 |
|
8 |
def clone_and_run():
|
9 |
# 設定環境變數中的倉庫地址和憑證
|
|
|
10 |
repo_url = os.getenv('HF_REPO_URL')
|
11 |
access_token = os.getenv('HF_ACCESS_TOKEN')
|
12 |
|
@@ -14,7 +15,7 @@ def clone_and_run():
|
|
14 |
raise EnvironmentError("請設定環境變數中的 HUGGING_FACE_REPO_URL 和 HUGGING_FACE_ACCESS_TOKEN")
|
15 |
|
16 |
# 構建帶有憑證的 URL
|
17 |
-
auth_repo_url = repo_url.replace('https://', f'https://{access_token}@')
|
18 |
|
19 |
try:
|
20 |
# 克隆倉庫
|
|
|
7 |
|
8 |
def clone_and_run():
|
9 |
# 設定環境變數中的倉庫地址和憑證
|
10 |
+
user = os.getenv('HF_USER')
|
11 |
repo_url = os.getenv('HF_REPO_URL')
|
12 |
access_token = os.getenv('HF_ACCESS_TOKEN')
|
13 |
|
|
|
15 |
raise EnvironmentError("請設定環境變數中的 HUGGING_FACE_REPO_URL 和 HUGGING_FACE_ACCESS_TOKEN")
|
16 |
|
17 |
# 構建帶有憑證的 URL
|
18 |
+
auth_repo_url = repo_url.replace('https://', f'https://{user}:{access_token}@')
|
19 |
|
20 |
try:
|
21 |
# 克隆倉庫
|
docker-compose.yml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.8'
|
2 |
+
|
3 |
+
services:
|
4 |
+
app1:
|
5 |
+
build: .
|
6 |
+
networks:
|
7 |
+
- default
|
8 |
+
- nginx-bridge
|
9 |
+
environment:
|
10 |
+
- CUDA_VISIBLE_DEVICES=all
|
11 |
+
# - LETSENCRYPT_HOST=vits-hat-tts.gohakka.org
|
12 |
+
# - VIRTUAL_HOST=vits-hat-tts.gohakka.org
|
13 |
+
- VIRTUAL_PORT=7860
|
14 |
+
ports:
|
15 |
+
- 7862:7860
|
16 |
+
# expose:
|
17 |
+
# - "7860"
|
18 |
+
env_file:
|
19 |
+
- .env
|
20 |
+
|
21 |
+
networks:
|
22 |
+
nginx-bridge:
|
23 |
+
external: true
|
24 |
+
|
25 |
+
|
26 |
+
# docker run -it --entrypoint bash -p 7862:7860 --env-file .env -v $(pwd):/home/user/app taiwanese-hakka-whisper-app1
|