From f8dc3252568dbe25b76f6662a16b7c04b66c70a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Thu, 13 Mar 2025 11:55:15 +0800 Subject: [PATCH] add docker (#4000) * add docker * fix unit error > Type promotion * fix url --- docker/ubuntu20-cpu/Dockerfile | 17 +++++++++++++++++ tests/unit/asr/reverse_pad_list.py | 11 +++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 docker/ubuntu20-cpu/Dockerfile diff --git a/docker/ubuntu20-cpu/Dockerfile b/docker/ubuntu20-cpu/Dockerfile new file mode 100644 index 000000000..bb113b2f2 --- /dev/null +++ b/docker/ubuntu20-cpu/Dockerfile @@ -0,0 +1,17 @@ +FROM registry.baidubce.com/paddlepaddle/paddle:3.0.0b1 +LABEL maintainer="ext_paddle_oss@baidu.com" + +RUN apt-get update \ + && apt-get install libsndfile-dev libsndfile1 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN git clone --depth 1 https://github.com/PaddlePaddle/PaddleSpeech.git /home/PaddleSpeech +RUN pip3 uninstall mccabe -y ; exit 0; +RUN pip3 install multiprocess==0.70.12 importlib-metadata==4.2.0 dill==0.3.4 + +WORKDIR /home/PaddleSpeech/ +RUN python setup.py bdist_wheel +RUN pip install dist/*.whl -i https://pypi.tuna.tsinghua.edu.cn/simple + +CMD ['bash'] diff --git a/tests/unit/asr/reverse_pad_list.py b/tests/unit/asr/reverse_pad_list.py index 215ed5ceb..1b63890a0 100644 --- a/tests/unit/asr/reverse_pad_list.py +++ b/tests/unit/asr/reverse_pad_list.py @@ -65,14 +65,16 @@ def reverse_pad_list_with_sos_eos(r_hyps, max_len = paddle.max(r_hyps_lens) index_range = paddle.arange(0, max_len, 1) seq_len_expand = r_hyps_lens.unsqueeze(1) - seq_mask = seq_len_expand > index_range # (beam, max_len) + seq_mask = seq_len_expand > index_range.astype( + seq_len_expand.dtype) # (beam, max_len) - index = (seq_len_expand - 1) - index_range # (beam, max_len) + index = (seq_len_expand - 1) - index_range.astype( + seq_len_expand.dtype) # (beam, max_len) # >>> index # >>> tensor([[ 2, 1, 0], # >>> [ 2, 1, 0], # >>> [ 0, -1, -2]]) - index = index * seq_mask + index = index * seq_mask.astype(index.dtype) # >>> index # >>> tensor([[2, 1, 0], @@ -103,7 +105,8 @@ def reverse_pad_list_with_sos_eos(r_hyps, # >>> tensor([[3, 2, 1], # >>> [4, 8, 9], # >>> [2, 2, 2]]) - r_hyps = paddle.where(seq_mask, r_hyps, eos) + r_hyps = paddle.where(seq_mask, r_hyps, + paddle.to_tensor(eos, dtype=r_hyps.dtype)) # >>> r_hyps # >>> tensor([[3, 2, 1], # >>> [4, 8, 9],