Spaces:
Running
on
L4
Running
on
L4
ftshijt
commited on
Commit
·
0c542b8
1
Parent(s):
4098e5e
apply additional fix with the setup
Browse files- Dockerfile +24 -22
- app.py +3 -3
Dockerfile
CHANGED
@@ -1,8 +1,16 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
|
|
|
4 |
|
|
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Install system dependencies
|
8 |
RUN apt-get update && apt-get install -y \
|
@@ -15,27 +23,23 @@ RUN apt-get update && apt-get install -y \
|
|
15 |
|
16 |
# Create directories with permissive permissions
|
17 |
RUN mkdir -p /.cache && chmod -R 777 /.cache \
|
18 |
-
&& mkdir -p /app/.cache && chmod -R 777 /app/.cache \
|
19 |
-
&& mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface \
|
20 |
-
&& mkdir -p /app/.cache/huggingface/token && chmod -R 777 /app/.cache/huggingface \
|
21 |
-
&& echo "unused_dummy_token" > /app/.cache/huggingface/token \
|
22 |
-
&& chmod 777 /app/.cache/huggingface/token \
|
23 |
&& mkdir -p /usr/local/share/nltk_data && chmod -R 777 /usr/local/share/nltk_data \
|
24 |
&& mkdir -p /tmp/librosa_cache && chmod -R 777 /tmp/librosa_cache
|
25 |
|
26 |
# Create token file in the root directory in case it still looks there
|
27 |
-
RUN mkdir -p /root/.cache/huggingface && chmod -R 777 /root/.cache/huggingface
|
28 |
-
&& echo "unused_dummy_token" > /root/.cache/huggingface/token \
|
29 |
-
&& chmod 777 /root/.cache/huggingface/token
|
30 |
|
31 |
# Create the data directories referenced in app.py
|
32 |
-
RUN mkdir -p /app/data/uploads && chmod -R 777 /app/data/uploads \
|
33 |
-
&& mkdir -p /app/data/results && chmod -R 777 /app/data/results \
|
34 |
-
&& mkdir -p /app/data/configs && chmod -R 777 /app/data/configs
|
35 |
|
36 |
|
37 |
# Copy requirements file
|
38 |
-
COPY requirements.txt .
|
39 |
|
40 |
# Install Python dependencies
|
41 |
RUN pip install --no-cache-dir -U pip && \
|
@@ -47,17 +51,17 @@ RUN git clone https://github.com/wavlab-speech/versa.git && \
|
|
47 |
pip install -e .
|
48 |
|
49 |
# Set up data directories
|
50 |
-
RUN mkdir -p /app/data/configs /app/data/uploads /app/data/results && \
|
51 |
-
chmod -R 777 /app/data
|
52 |
|
53 |
# Copy universal metrics YAML file
|
54 |
-
COPY universal_metrics.yaml /app/data/configs/
|
55 |
|
56 |
# Copy application code
|
57 |
-
COPY app.py .
|
58 |
|
59 |
# Create installation complete indicator
|
60 |
-
RUN touch /app/versa/.installation_complete
|
61 |
|
62 |
# Set port
|
63 |
EXPOSE 7860
|
@@ -66,7 +70,7 @@ EXPOSE 7860
|
|
66 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
67 |
ENV NLTK_DATA=/usr/local/share/nltk_data
|
68 |
ENV PYTHONUNBUFFERED=1
|
69 |
-
ENV HF_HOME
|
70 |
# Disable token verification for huggingface models
|
71 |
ENV TRANSFORMERS_OFFLINE=1
|
72 |
ENV HF_DATASETS_OFFLINE=1
|
@@ -82,10 +86,8 @@ ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/
|
|
82 |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
83 |
|
84 |
# Make everything accessible
|
85 |
-
RUN
|
86 |
-
RUN chmod -R 777 /app
|
87 |
RUN chmod -R 777 /usr/local/lib/python3.9/site-packages
|
88 |
-
RUN chmod -R 777 /root
|
89 |
|
90 |
# Run the application
|
91 |
CMD ["python", "app.py"]
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
+
# Set up a new user named "user" with user ID 1000
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
|
6 |
+
# Switch to the "user" user
|
7 |
+
USER user
|
8 |
|
9 |
+
# Set home to the user's home directory
|
10 |
+
ENV HOME=/home/user
|
11 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
12 |
+
|
13 |
+
WORKDIR $HOME/app
|
14 |
|
15 |
# Install system dependencies
|
16 |
RUN apt-get update && apt-get install -y \
|
|
|
23 |
|
24 |
# Create directories with permissive permissions
|
25 |
RUN mkdir -p /.cache && chmod -R 777 /.cache \
|
26 |
+
&& mkdir -p $HOME/app/.cache && chmod -R 777 $HOME/app/.cache \
|
27 |
+
&& mkdir -p $HOME/app/.cache/huggingface && chmod -R 777 $HOME/app/.cache/huggingface \
|
28 |
+
&& mkdir -p $HOME/app/.cache/huggingface/token && chmod -R 777 $HOME/app/.cache/huggingface \
|
|
|
|
|
29 |
&& mkdir -p /usr/local/share/nltk_data && chmod -R 777 /usr/local/share/nltk_data \
|
30 |
&& mkdir -p /tmp/librosa_cache && chmod -R 777 /tmp/librosa_cache
|
31 |
|
32 |
# Create token file in the root directory in case it still looks there
|
33 |
+
RUN mkdir -p /root/.cache/huggingface && chmod -R 777 /root/.cache/huggingface
|
|
|
|
|
34 |
|
35 |
# Create the data directories referenced in app.py
|
36 |
+
RUN mkdir -p $HOME/app/data/uploads && chmod -R 777 $HOME/app/data/uploads \
|
37 |
+
&& mkdir -p $HOME/app/data/results && chmod -R 777 $HOME/app/data/results \
|
38 |
+
&& mkdir -p $HOME/app/data/configs && chmod -R 777 $HOME/app/data/configs
|
39 |
|
40 |
|
41 |
# Copy requirements file
|
42 |
+
COPY --chown=user requirements.txt .
|
43 |
|
44 |
# Install Python dependencies
|
45 |
RUN pip install --no-cache-dir -U pip && \
|
|
|
51 |
pip install -e .
|
52 |
|
53 |
# Set up data directories
|
54 |
+
RUN mkdir -p $HOME/app/data/configs $HOME/app/data/uploads $HOME/app/data/results && \
|
55 |
+
chmod -R 777 $HOME/app/data
|
56 |
|
57 |
# Copy universal metrics YAML file
|
58 |
+
COPY --chown=user universal_metrics.yaml $HOME/app/data/configs/
|
59 |
|
60 |
# Copy application code
|
61 |
+
COPY --chown=user app.py .
|
62 |
|
63 |
# Create installation complete indicator
|
64 |
+
RUN touch $HOME/app/versa/.installation_complete
|
65 |
|
66 |
# Set port
|
67 |
EXPOSE 7860
|
|
|
70 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
71 |
ENV NLTK_DATA=/usr/local/share/nltk_data
|
72 |
ENV PYTHONUNBUFFERED=1
|
73 |
+
ENV HF_HOME=$HOME/.cache/huggingface
|
74 |
# Disable token verification for huggingface models
|
75 |
ENV TRANSFORMERS_OFFLINE=1
|
76 |
ENV HF_DATASETS_OFFLINE=1
|
|
|
86 |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/
|
87 |
|
88 |
# Make everything accessible
|
89 |
+
RUN chmod -R 777 $HOME/app
|
|
|
90 |
RUN chmod -R 777 /usr/local/lib/python3.9/site-packages
|
|
|
91 |
|
92 |
# Run the application
|
93 |
CMD ["python", "app.py"]
|
app.py
CHANGED
@@ -18,12 +18,12 @@ os.makedirs(nltk_data_dir, exist_ok=True)
|
|
18 |
print(f"NLTK data directory set to: {nltk_data_dir}")
|
19 |
|
20 |
# VERSA paths - these are set by the Dockerfile
|
21 |
-
VERSA_ROOT = "/app/versa"
|
22 |
VERSA_BIN = os.path.join(VERSA_ROOT, "versa", "bin", "scorer.py")
|
23 |
VERSA_CONFIG_DIR = os.path.join(VERSA_ROOT, "egs")
|
24 |
|
25 |
# Data directories - also set up by the Dockerfile
|
26 |
-
DATA_DIR = "/app/data"
|
27 |
UPLOAD_DIR = os.path.join(DATA_DIR, "uploads")
|
28 |
RESULTS_DIR = os.path.join(DATA_DIR, "results")
|
29 |
CONFIG_DIR = os.path.join(DATA_DIR, "configs")
|
@@ -330,7 +330,7 @@ def evaluate_audio(gt_file, pred_file, metric_config, include_timestamps=False):
|
|
330 |
env["NLTK_DATA"] = nltk_data_dir
|
331 |
|
332 |
# Set huggingface cache
|
333 |
-
env["HF_HOME"] = "/
|
334 |
|
335 |
process = subprocess.run(
|
336 |
cmd,
|
|
|
18 |
print(f"NLTK data directory set to: {nltk_data_dir}")
|
19 |
|
20 |
# VERSA paths - these are set by the Dockerfile
|
21 |
+
VERSA_ROOT = "/home/user/app/versa"
|
22 |
VERSA_BIN = os.path.join(VERSA_ROOT, "versa", "bin", "scorer.py")
|
23 |
VERSA_CONFIG_DIR = os.path.join(VERSA_ROOT, "egs")
|
24 |
|
25 |
# Data directories - also set up by the Dockerfile
|
26 |
+
DATA_DIR = "/home/user/app/data"
|
27 |
UPLOAD_DIR = os.path.join(DATA_DIR, "uploads")
|
28 |
RESULTS_DIR = os.path.join(DATA_DIR, "results")
|
29 |
CONFIG_DIR = os.path.join(DATA_DIR, "configs")
|
|
|
330 |
env["NLTK_DATA"] = nltk_data_dir
|
331 |
|
332 |
# Set huggingface cache
|
333 |
+
env["HF_HOME"] = "/home/user/.cache/huggingface"
|
334 |
|
335 |
process = subprocess.run(
|
336 |
cmd,
|