网站联盟广告名词解释,汕头保安公司,游戏搭建平台,wordpress企业主题模板文章目录 一、环境搭建#xff08;1#xff09;新建虚拟环境#xff0c;并进入#xff08;2#xff09;安装pyTorch#xff08;3#xff09;进入代码文件夹#xff0c;批量安装包#xff08;4#xff09;安装其他需要的包 二、数据集准备#xff08;1#xff09;下… 文章目录 一、环境搭建1新建虚拟环境并进入2安装pyTorch3进入代码文件夹批量安装包4安装其他需要的包 二、数据集准备1下载数据集2修改配置参数3创建微调数据集4解压outputs.tar.gz三、训练1默认cpu2默认gpu3修改参数gpu 四、推理1模型导出2模型评估3推理 报错1soundfile.LibsndfileError: Error opening C:\\Users\\Lenovo\\AppData\\Local\\Temp\\tmps0ogpyqy.wav: System error.2FileNotFoundError: [WinError 2] 系统找不到指定的文件。3TypeError: beat_track() takes 0 positional arguments but 1 positional argument (and 2 keyword-only arguments) were given4TypeError: chroma_cqt() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given5numpy.core._exceptions._ArrayMemoryError: Unable to allocate 1.11 GiB for an array with shape (54134, 1377) and data type complex1286UserWarning:The version_base parameter is not specified.7FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.8torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 562.00 MiB (GPU 0; 15.99 GiB total capacity; 14.06 GiB already allocated; 0 bytes free; 14.72 GiB reserved in total by PyTorch) If reserved memory is allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF9WARNING:__main__:Model 81de367c has less epoch than expected (8 / 360) 写在最后 代码下载 这是一个音频提取、分离的项目 一、环境搭建
1新建虚拟环境并进入
conda create -n demucs python3.8
activate demucs2安装pyTorch
到pyTorch官网选择对应配置 这个是我的配置 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu1183进入代码文件夹批量安装包 d:
cd D:\data\cqZhang\demucs-3
pip install -r requirements.txt4安装其他需要的包
pip install librosa二、数据集准备
1下载数据集
使用Musdb HQ 数据集 获取路径有 https://zenodo.org/record/3338373 https://www.kaggle.com/datasets/ayu055/musdb18hq 数据集可以放在“\checkpoint\defossez\datasets\musdbhq”路径下 这与代码原来的位置应该是一致的 2修改配置参数
The dset.musdb key inside conf/config.yaml.The variable MUSDB_PATH inside tools/automix.py. 我本来使用的是相对路径但是他貌似找不到后来改成绝对路径 其他的路径也一样如果找不到就要改成绝对路径 3创建微调数据集
原来的命令是export NUMBA_NUM_THREADS1; python3 -m tools.automix但它是linux上的命令 将其改为set NUMBA_NUM_THREADS1 python -m tools.automix 运行结束会在项目目录下产生tmp文件夹里面有新的数据集 修改 conf/config.yaml.中的 dset.musdb 修改 conf/dset/auto_mus.yaml 中的 dset.wav OUTPATH
4解压outputs.tar.gz
tar xvf outputs.tar.gz三、训练 训练有三种命令 我只尝试了第二种 1默认cpu
dora info -f 81de367cthis will show the hyper-parameter used by a specific XP. Be careful some overrides might present twice, and the right most one will give you the right value for it. 这将显示特定XP使用的超参数。 请注意有些覆盖可能会出现两次最正确的一次将为您提供正确的值。 2默认gpu
dora run -d -f 81de367c注意如果修改了数据集要在目录下删除metadata文件夹否则会出错。 run an XP with the hyper-parameters from XP 81de367c. -d is for distributed, it will use all available GPUs. 使用XP 81de367c中的超参数运行XP。 -d是分布式的它将使用所有可用的GPU。 3修改参数gpu
dora run -d -f 81de367c hdemucs.channels32start from the config of XP 81de367c but change some hyper-params. This will give you a new XP with a new signature (here 3fe9c332). 从XP 81de367c的配置开始但更改了一些超参数。 这将为您提供一个带有新签名的新XP此处为3fe9c332。 四、推理
1模型导出
python -m tools.export 81de367c2模型评估
python -m tools.test_pretrained --repo ./release_models -n 81de367c3推理
python -m demucs --repo ./release_models -n 81de367c --mp3 D:\data\cqZhang\001.mp3保存位置./separated
报错
1soundfile.LibsndfileError: Error opening ‘C:\Users\Lenovo\AppData\Local\Temp\tmps0ogpyqy.wav’: System error. 在linux上运行会创建一个临时文件且程序退出后该临时文件会自动删除 但是在windows上运行时不能打开创建的临时文件 Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). 在命名的临时文件仍然打开的情况下该名称是否可以用于第二次打开文件因平台而异它可以在Unix上使用不能在Windows NT或更高版本上使用。 处理 方法1. 更改临时文件保存方式不保存到系统的临时文件夹里 方法2. 增加参数deleteFalse手动删除 我采用方法2 执行后会报其他错误这是另一个问题了 2FileNotFoundError: [WinError 2] 系统找不到指定的文件。 出现这个错误原因大概有三种 1、先查看路径是否正确 2、再查看该文件是否存在 3、如果还没解决问题最后很可能就是该命令在dos环境内无法使用 处理 根据实际情况我判断是第三种问题 到这里下载一个程序 解压后放在项目目录下 已经成功执行了
3TypeError: beat_track() takes 0 positional arguments but 1 positional argument (and 2 keyword-only arguments) were given 说是参数个数不匹配的问题其实并不是 处理
# 将下列代码
tempo, events beat_track(drums.numpy(), unitstime, srSR)# 改为
tempo, events beat_track(ydrums.numpy(), unitstime, srSR)4TypeError: chroma_cqt() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given 这个问题与上面那个问题一样 说是参数个数不匹配的问题其实并不是 处理
# 将下列代码
kr torch.from_numpy(chroma_cqt(bass.numpy(), srSR))# 改为
kr torch.from_numpy(chroma_cqt(y bass.numpy(), srSR))5numpy.core._exceptions._ArrayMemoryError: Unable to allocate 1.11 GiB for an array with shape (54134, 1377) and data type complex128 内存不足 这个我没有去思考如何减少内存的使用 也许减小数据集有效 我的处理方式是换一台大内存的机器 它的内存需求不超过40g 6UserWarning:The version_base parameter is not specified. 这是一个版本警告其实无关紧要 完整的警告如下 D:\app\anaconda\envs\demucs\lib\site-packages\dora\hydra.py:279: UserWarning: The version_base parameter is not specified. Please specify a compatability version level, or None. Will assume defaults for version 1.1 with initialize_config_dir(str(self.full_config_path), job_nameself._job_name, 处理 加上参数version_base1.1
7FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0. 处理 首先我在demucs/repitch的sp.run()中加入参数shellTrue 再次运行dora run -d -f 81de367c,报错信息出现变化 我运行命令soundstretch C:\\Users\\Lenovo\\AppData\\Local\\Temp\\tmps9ifi1_z.wav C:\\Users\\Lenovo\\AppData\\Local\\Temp\\tmp44v82njg.wav -pitch2 -tempo-3.226039执行成功 说明文件其实是存在的但是不知道为啥不能执行成功
第二处应该是编码格式的问题我将raise RuntimeError(fCould not change bpm because {error.stderr.decode(utf-8)})修改为raise RuntimeError(fCould not change bpm because {error.stderr.decode(gbk)})解决 这可能就是报错的主要原因了 将soundstretch放到下面目录 运行出现一下结果应该是没问题了。内存不足修改batch_size
8torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 562.00 MiB (GPU 0; 15.99 GiB total capacity; 14.06 GiB already allocated; 0 bytes free; 14.72 GiB reserved in total by PyTorch) If reserved memory is allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF 处理 修改conf/config.yaml里的batch_size 默认64但是我只有16G的显存设置成4目前恰好运行不知道能不能运行到结束。 ##9FileExistsError: [WinError 183] 当文件已存在时无法创建该文件。 处理 方法1修改重命名方式改成强制覆盖 方法2在重命名前删除已有文件 方法3修改命名方式比如加上日期时间
9WARNING:main:Model 81de367c has less epoch than expected (8 / 360) 模型没有训练够就想导出。
处理 只是一个警告不理会也没关系。 介意的话把这里改小即可。
写在最后
写一半的时候有其他的事停了大半个月 现在又有事了匆匆忙忙把推理部分写上 后面有机会再补充 有机会尝试自己构造数据集训练 文章转载自: http://www.morning.kcsx.cn.gov.cn.kcsx.cn http://www.morning.jxhlx.cn.gov.cn.jxhlx.cn http://www.morning.ggtgl.cn.gov.cn.ggtgl.cn http://www.morning.rgpy.cn.gov.cn.rgpy.cn http://www.morning.zwgbz.cn.gov.cn.zwgbz.cn http://www.morning.swbhq.cn.gov.cn.swbhq.cn http://www.morning.bwgrd.cn.gov.cn.bwgrd.cn http://www.morning.saastob.com.gov.cn.saastob.com http://www.morning.yrpg.cn.gov.cn.yrpg.cn http://www.morning.webpapua.com.gov.cn.webpapua.com http://www.morning.qxlgt.cn.gov.cn.qxlgt.cn http://www.morning.xysxj.com.gov.cn.xysxj.com http://www.morning.sfdky.cn.gov.cn.sfdky.cn http://www.morning.pzjrm.cn.gov.cn.pzjrm.cn http://www.morning.qjfkz.cn.gov.cn.qjfkz.cn http://www.morning.rntyn.cn.gov.cn.rntyn.cn http://www.morning.lcxdm.cn.gov.cn.lcxdm.cn http://www.morning.mkygc.cn.gov.cn.mkygc.cn http://www.morning.rqpgk.cn.gov.cn.rqpgk.cn http://www.morning.bypfj.cn.gov.cn.bypfj.cn http://www.morning.qbzfp.cn.gov.cn.qbzfp.cn http://www.morning.nydgg.cn.gov.cn.nydgg.cn http://www.morning.ksjnl.cn.gov.cn.ksjnl.cn http://www.morning.ydxwj.cn.gov.cn.ydxwj.cn http://www.morning.brjq.cn.gov.cn.brjq.cn http://www.morning.wqcz.cn.gov.cn.wqcz.cn http://www.morning.dbylp.cn.gov.cn.dbylp.cn http://www.morning.nqxdg.cn.gov.cn.nqxdg.cn http://www.morning.tbplf.cn.gov.cn.tbplf.cn http://www.morning.qzsmz.cn.gov.cn.qzsmz.cn http://www.morning.tmbfz.cn.gov.cn.tmbfz.cn http://www.morning.nfbnl.cn.gov.cn.nfbnl.cn http://www.morning.grxsc.cn.gov.cn.grxsc.cn http://www.morning.mdpcz.cn.gov.cn.mdpcz.cn http://www.morning.bzjpn.cn.gov.cn.bzjpn.cn http://www.morning.pxtgf.cn.gov.cn.pxtgf.cn http://www.morning.tfqfm.cn.gov.cn.tfqfm.cn http://www.morning.zqwqy.cn.gov.cn.zqwqy.cn http://www.morning.lekbiao.com.gov.cn.lekbiao.com http://www.morning.kjrlp.cn.gov.cn.kjrlp.cn http://www.morning.lfjmp.cn.gov.cn.lfjmp.cn http://www.morning.nstml.cn.gov.cn.nstml.cn http://www.morning.qxnns.cn.gov.cn.qxnns.cn http://www.morning.pffqh.cn.gov.cn.pffqh.cn http://www.morning.rqqn.cn.gov.cn.rqqn.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.llllcc.com.gov.cn.llllcc.com http://www.morning.mmhyx.cn.gov.cn.mmhyx.cn http://www.morning.jpydf.cn.gov.cn.jpydf.cn http://www.morning.jgmlb.cn.gov.cn.jgmlb.cn http://www.morning.rqlbp.cn.gov.cn.rqlbp.cn http://www.morning.lyhry.cn.gov.cn.lyhry.cn http://www.morning.lnyds.cn.gov.cn.lnyds.cn http://www.morning.lxlfr.cn.gov.cn.lxlfr.cn http://www.morning.ghphp.cn.gov.cn.ghphp.cn http://www.morning.pqsys.cn.gov.cn.pqsys.cn http://www.morning.fwqgy.cn.gov.cn.fwqgy.cn http://www.morning.tnzwm.cn.gov.cn.tnzwm.cn http://www.morning.prxqd.cn.gov.cn.prxqd.cn http://www.morning.wftrs.cn.gov.cn.wftrs.cn http://www.morning.dmwbs.cn.gov.cn.dmwbs.cn http://www.morning.nsfxt.cn.gov.cn.nsfxt.cn http://www.morning.syssdz.cn.gov.cn.syssdz.cn http://www.morning.tbkqs.cn.gov.cn.tbkqs.cn http://www.morning.kdtdh.cn.gov.cn.kdtdh.cn http://www.morning.gpryk.cn.gov.cn.gpryk.cn http://www.morning.jqzns.cn.gov.cn.jqzns.cn http://www.morning.grjh.cn.gov.cn.grjh.cn http://www.morning.fxxmj.cn.gov.cn.fxxmj.cn http://www.morning.rmkyb.cn.gov.cn.rmkyb.cn http://www.morning.lpnb.cn.gov.cn.lpnb.cn http://www.morning.flchj.cn.gov.cn.flchj.cn http://www.morning.xsjfk.cn.gov.cn.xsjfk.cn http://www.morning.hdzty.cn.gov.cn.hdzty.cn http://www.morning.ktcrr.cn.gov.cn.ktcrr.cn http://www.morning.zgdnd.cn.gov.cn.zgdnd.cn http://www.morning.gqbtw.cn.gov.cn.gqbtw.cn http://www.morning.ybgcn.cn.gov.cn.ybgcn.cn http://www.morning.jhtrb.cn.gov.cn.jhtrb.cn http://www.morning.wknj.cn.gov.cn.wknj.cn