(尝试支持音频到审计的生成是在我的待办事项列表中,因此您可以输入音乐曲目,而LDM可以帮助合并它们〜)
设置超级简单!只需按照以下说明:
pip install -r gradio/requirements.txt
python gradio/gradio_app.py
我们必须承认,UNET体系结构在主观音乐性方面仍然具有一定的概率优势,但这并未在指标中衡量。而且,我们确实有一些模型在指标上更好或经过更长的培训,但是我们观察到,在训练过长的时间后,这些模型通常会变得较低,因此我们选择了一种模型,该模型是指标作为开源样本的指标。 。如果您需要更多模型(极端的指标追击或极端的音乐追求,请与我联系)
没有任何精美的设计,只有优质的注入,并享受您的优美音乐
从https://huggingface.co/lichang0928/qa-mdt的QA-MDT模型的主要检查点下降
对于中国用户,您还可以通过以下链接下载检查站:
https://pan.baidu.com/s/1n0xqvxtf_x9i7fwb07lpqw?pwd=9nkt
该存储库提供了QA-MDT的实现,该存储库集成了音乐生成的最新模型。代码和方法基于以下存储库:
Python 3.10
qamdt.yaml在培训之前,您需要下载./audioldm_train/config/mos_as_token/qa_mdt.yaml和offset_pretretained_checkpoints.json中所需的额外ckpts。
指出:所有上述检查点都可以从以下下载:
flan-t5大
clap_music
罗伯塔基地
其他的
sh run.sh我们的模型已经有很好的预言。如果您想对其进行重新训练或微调,则可以选择使用或不使用我们的质量检查策略。我们提供几种培训策略:
PixArt_MDTPixart_MDT_MOS_AS_TOKENPixArt_Slowyou can just follow AudioLDM and make your dataset as illustrated in our paper (method part)要训练或微调,只需在audioldm_train.modules.diffusionmodules.PixArt.Your_Class中更改"Your_Class" 。
您也可以尝试修改补丁大小,重叠大小以达到最佳性能并计算资源(请参阅Arxiv Paper中的我们的附录)
我们使用LMDB数据集格式进行培训。您可以根据自己的培训需求修改数据加载器。
如果您想遵循我们的过程(尽管我们不建议它,因为它可能很复杂),这就是您可以创建玩具LMDB数据集的方法:
创建一个原始文件
首先,创建一个名为datum_all.proto的文件,其中包含以下内容:
syntax = "proto2" ;
message Datum_all {
repeated float wav_file = 1 ;
required string caption_original = 2 ;
repeated string caption_generated = 3 ;
required float mos = 4 ;
}生成python结合
(您的原始版本应为3.4,您可以在此处下载)
在您的终端中运行以下命令以生成Python绑定:
protoc --python_out=./ datum_all.proto这将创建一个名为datum_all_pb2.py的文件。我们还在数据集文件夹中提供了此文件,您可以检查它是否与生成的文件匹配。切勿尝试修改此文件,因为这样做可能会导致错误。
以下Python脚本演示了如何以LMDB格式准备数据集:
import torch
import os
import lmdb
import time
import numpy as np
import librosa
import os
import soundfile as sf
import io
from datum_all_pb2 import Datum_all as Datum_out
device = 'cpu'
count = 0
total_hours = 0
# Define paths
lmdb_file = '/disk1/changli/toy_lmdb'
toy_path = '/disk1/changli/audioset'
lmdb_key = os . path . join ( lmdb_file , 'data_key.key' )
# Open LMDB environment
env = lmdb . open ( lmdb_file , map_size = 1e12 )
txn = env . begin ( write = True )
final_keys = []
def _resample_load_librosa ( path : str , sample_rate : int , downmix_to_mono : bool , ** kwargs ):
"""Load and resample audio using librosa."""
src , sr = librosa . load ( path , sr = sample_rate , mono = downmix_to_mono , ** kwargs )
return src
start_time = time . time ()
# Walk through the dataset directory
for root , _ , files in os . walk ( toy_path ):
for file in files :
audio_path = os . path . join ( root , file )
key_tmp = audio_path . replace ( '/' , '_' )
audio = _resample_load_librosa ( audio_path , 16000 , True )
# Create a new Datum object
datum = Datum_out ()
datum . wav_file . extend ( audio )
datum . caption_original = 'audio' . encode ()
datum . caption_generated . append ( 'audio' . encode ())
datum . mos = - 1
# Write to LMDB
txn . put ( key_tmp . encode (), datum . SerializeToString ())
final_keys . append ( key_tmp )
count += 1
total_hours += 1.00 / 60 / 10
if count % 1 == 0 :
elapsed_time = time . time () - start_time
print ( f' { count } files written, time: { elapsed_time :.2f } s' )
txn . commit ()
txn = env . begin ( write = True )
# Finalize transaction
try :
total_time = time . time () - start_time
print ( f'Packing completed: { count } files written, total_hours: { total_hours :.2f } , time: { total_time :.2f } s' )
txn . commit ()
except :
pass
env . close ()
# Save the LMDB keys
with open ( lmdb_key , 'w' ) as f :
for key in final_keys :
f . write ( key + ' n ' )否则,您只能在AudiOldM中使用数据载加载程序
将生成的LMDB路径及其相应的密钥文件路径输入到配置
开始训练
sh infer/infer.sh
# you may change the infer.sh for witch quality level you want to infer
# defaultly, it should be set to 5 which represent highest quality
# Additionally, it may be useful to change the prompt with text prefix "high quality",
# which match the training process and may further improve performance 这是我第一次开源这样一个项目,代码,组织,开源可能不是完美的。如果您对我们的模型,代码和数据集有任何疑问,请随时通过以下链接与我联系,我期待任何建议:
我将尽力在将来提供更多有关音乐和音频的项目〜
如果您觉得这个项目有用,请考虑引用:
@article{li2024quality,
title={Quality-aware Masked Diffusion Transformer for Enhanced Music Generation},
author={Li, Chang and Wang, Ruoyu and Liu, Lijuan and Du, Jun and Sun, Yixuan and Guo, Zilu and Zhang, Zhenrong and Jiang, Yuan},
journal={arXiv preprint arXiv:2405.15863},
year={2024}
}