-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
187 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG WHISPER_MODEL=base | ||
ARG LANG=en | ||
ARG TORCH_HOME=/cache/torch | ||
ARG HF_HOME=/cache/huggingface | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal as python | ||
|
||
RUN microdnf -y install python3.11 python3.11-devel python3.11-pip && \ | ||
microdnf clean all | ||
RUN ln -s /usr/bin/python3.11 /usr/bin/python3 && \ | ||
ln -s /usr/bin/pip3.11 /usr/bin/pip | ||
|
||
RUN python3 -m venv /venv | ||
ENV PATH="/venv/bin:$PATH" | ||
|
||
# Missing dependencies for arm64 | ||
# https://github.com/jim60105/docker-whisperX/issues/14 | ||
ARG TARGETPLATFORM | ||
RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ | ||
microdnf -y install libgomp libsndfile && microdnf clean all; \ | ||
fi | ||
|
||
FROM python as build | ||
|
||
# Install build time requirements | ||
RUN microdnf -y install git && \ | ||
microdnf clean all | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip pip install torch torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 | ||
|
||
# Install whisperX | ||
COPY ./whisperX /code | ||
RUN --mount=type=cache,target=/root/.cache/pip pip install /code | ||
|
||
|
||
FROM build as load_model | ||
|
||
ARG TORCH_HOME | ||
ARG HF_HOME | ||
|
||
# Preload vad model | ||
RUN python3 -c 'from whisperx.vad import load_vad_model; load_vad_model("cpu");' | ||
|
||
# Preload fast-whisper | ||
ARG WHISPER_MODEL | ||
RUN python3 -c 'import faster_whisper; model = faster_whisper.WhisperModel("'${WHISPER_MODEL}'")' | ||
|
||
# Preload align model | ||
ARG LANG | ||
COPY load_align_model.py . | ||
RUN python3 load_align_model.py ${LANG} | ||
|
||
|
||
FROM python as final | ||
|
||
USER 1001 | ||
|
||
# ffmpeg | ||
COPY --link --from=mwader/static-ffmpeg:6.0 /ffmpeg /usr/local/bin/ | ||
COPY --link --from=mwader/static-ffmpeg:6.0 /ffprobe /usr/local/bin/ | ||
|
||
# Copy venv | ||
COPY --link --from=build /venv /venv | ||
|
||
COPY --chown=1001 --from=load_model /cache /cache | ||
|
||
WORKDIR /app | ||
ARG TORCH_HOME | ||
ARG HF_HOME | ||
ENV TORCH_HOME=${TORCH_HOME} | ||
ENV HF_HOME=${HF_HOME} | ||
|
||
ARG WHISPER_MODEL | ||
ENV WHISPER_MODEL=${WHISPER_MODEL} | ||
ARG LANG | ||
ENV LANG=${LANG} | ||
|
||
STOPSIGNAL SIGINT | ||
ENTRYPOINT whisperx --model ${WHISPER_MODEL} --language ${LANG} $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG TORCH_HOME=/cache/torch | ||
ARG HF_HOME=/cache/huggingface | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi-minimal as python | ||
|
||
# These libs are missing dependencies for arm64 | ||
RUN microdnf -y install python3.11 python3.11-devel python3.11-pip libgomp libsndfile && \ | ||
microdnf clean all | ||
RUN ln -s /usr/bin/python3.11 /usr/bin/python3 && \ | ||
ln -s /usr/bin/pip3.11 /usr/bin/pip | ||
|
||
RUN python3 -m venv /venv | ||
ENV PATH="/venv/bin:$PATH" | ||
|
||
FROM python as build | ||
|
||
# Install build time requirements | ||
RUN microdnf -y install git && \ | ||
microdnf clean all | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip pip install torch torchaudio --extra-index-url https://download.pytorch.org/whl/cu118 | ||
|
||
# Install whisperX | ||
COPY ./whisperX /code | ||
RUN --mount=type=cache,target=/root/.cache/pip pip install /code | ||
|
||
|
||
FROM python as final | ||
|
||
USER 1001 | ||
|
||
# ffmpeg | ||
COPY --link --from=mwader/static-ffmpeg:6.0 /ffmpeg /usr/local/bin/ | ||
COPY --link --from=mwader/static-ffmpeg:6.0 /ffprobe /usr/local/bin/ | ||
|
||
# Copy venv | ||
COPY --link --from=build /venv /venv | ||
|
||
WORKDIR /app | ||
ARG TORCH_HOME | ||
ARG HF_HOME | ||
ENV TORCH_HOME=${TORCH_HOME} | ||
ENV HF_HOME=${HF_HOME} | ||
|
||
ARG WHISPER_MODEL | ||
ENV WHISPER_MODEL=${WHISPER_MODEL} | ||
ARG LANG | ||
ENV LANG=${LANG} | ||
|
||
STOPSIGNAL SIGINT | ||
ENTRYPOINT whisperx $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters