Improve model card

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +105 -103
README.md CHANGED
@@ -1,104 +1,106 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
4
-
5
- # AudioX
6
-
7
- ## ๐ŸŽง AudioX: Diffusion Transformer for Anything-to-Audio Generation
8
-
9
- [TL;DR]: AudioX is a unified Diffusion Transformer model for Anything-to-Audio and Music Generation, capable of generating high-quality general audio and music, offering flexible natural language control, and seamlessly processing various modalities including text, video, image, music, and audio.
10
-
11
- ### Links
12
- - **[Paper](https://arxiv.org/abs/2503.10522)**: Explore the research behind AudioX.
13
- - **[Project](https://zeyuet.github.io/AudioX/)**: Visit the official project page for more information and updates.
14
-
15
-
16
- ## Clone the repository
17
- ```bash
18
- GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/Zeyue7/AudioX
19
- cd AudioX
20
-
21
- conda create -n AudioX python=3.8.20
22
- conda activate AudioX
23
- pip install git+https://github.com/ZeyueT/AudioX.git
24
- conda install -c conda-forge ffmpeg libsndfile
25
- ```
26
-
27
- ## Usage
28
-
29
- ```py
30
- import torch
31
- import torchaudio
32
- from einops import rearrange
33
- from stable_audio_tools import get_pretrained_model
34
- from stable_audio_tools.inference.generation import generate_diffusion_cond
35
- from stable_audio_tools.data.utils import read_video, merge_video_audio
36
- from stable_audio_tools.data.utils import load_and_process_audio
37
- import os
38
-
39
- device = "cuda" if torch.cuda.is_available() else "cpu"
40
-
41
- # Download model
42
- model, model_config = get_pretrained_model("Zeyue7/AudioX")
43
- sample_rate = model_config["sample_rate"]
44
- sample_size = model_config["sample_size"]
45
- target_fps = model_config["video_fps"]
46
- seconds_start = 0
47
- seconds_total = 10
48
-
49
- model = model.to(device)
50
-
51
- # for video-to-music generation
52
- video_path = "video.mp4"
53
- text_prompt = "Generate music for the video"
54
- audio_path = None
55
-
56
- video_tensor = read_video(video_path, seek_time=0, duration=seconds_total, target_fps=target_fps)
57
- audio_tensor = load_and_process_audio(audio_path, sample_rate, seconds_start, seconds_total)
58
-
59
- conditioning = [{
60
- "video_prompt": [video_tensor.unsqueeze(0)],
61
- "text_prompt": text_prompt,
62
- "audio_prompt": audio_tensor.unsqueeze(0),
63
- "seconds_start": seconds_start,
64
- "seconds_total": seconds_total
65
- }]
66
-
67
- # Generate stereo audio
68
- output = generate_diffusion_cond(
69
- model,
70
- steps=250,
71
- cfg_scale=7,
72
- conditioning=conditioning,
73
- sample_size=sample_size,
74
- sigma_min=0.3,
75
- sigma_max=500,
76
- sampler_type="dpmpp-3m-sde",
77
- device=device
78
- )
79
-
80
- # Rearrange audio batch to a single sequence
81
- output = rearrange(output, "b d n -> d (b n)")
82
-
83
- # Peak normalize, clip, convert to int16, and save to file
84
- output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
85
- torchaudio.save("output.wav", output, sample_rate)
86
-
87
- if video_path is not None and os.path.exists(video_path):
88
- merge_video_audio(video_path, "output.wav", "output.mp4", 0, seconds_total)
89
-
90
- ```
91
-
92
-
93
-
94
- ## Citation
95
- If you find our work useful, please consider citing:
96
-
97
- ```
98
- @article{tian2025audiox,
99
- title={AudioX: Diffusion Transformer for Anything-to-Audio Generation},
100
- author={Tian, Zeyue and Jin, Yizhu and Liu, Zhaoyang and Yuan, Ruibin and Tan, Xu and Chen, Qifeng and Xue, Wei and Guo, Yike},
101
- journal={arXiv preprint arXiv:2503.10522},
102
- year={2025}
103
- }
 
 
104
  ```
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ pipeline_tag: audio-to-audio
4
+ library_name: stable-audio-tools
5
+ ---
6
+
7
+ # AudioX
8
+
9
+ ## ๐ŸŽง AudioX: Diffusion Transformer for Anything-to-Audio Generation
10
+
11
+ [TL;DR]: AudioX is a unified Diffusion Transformer model for Anything-to-Audio and Music Generation, capable of generating high-quality general audio and music, offering flexible natural language control, and seamlessly processing various modalities including text, video, image, music, and audio.
12
+
13
+ ### Links
14
+ - **[Paper](https://arxiv.org/abs/2503.10522)**: Explore the research behind AudioX.
15
+ - **[Project](https://zeyuet.github.io/AudioX/)**: Visit the official project page for more information and updates.
16
+
17
+
18
+ ## Clone the repository
19
+ ```bash
20
+ GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/Zeyue7/AudioX
21
+ cd AudioX
22
+
23
+ conda create -n AudioX python=3.8.20
24
+ conda activate AudioX
25
+ pip install git+https://github.com/ZeyueT/AudioX.git
26
+ conda install -c conda-forge ffmpeg libsndfile
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```py
32
+ import torch
33
+ import torchaudio
34
+ from einops import rearrange
35
+ from stable_audio_tools import get_pretrained_model
36
+ from stable_audio_tools.inference.generation import generate_diffusion_cond
37
+ from stable_audio_tools.data.utils import read_video, merge_video_audio
38
+ from stable_audio_tools.data.utils import load_and_process_audio
39
+ import os
40
+
41
+ device = "cuda" if torch.cuda.is_available() else "cpu"
42
+
43
+ # Download model
44
+ model, model_config = get_pretrained_model("Zeyue7/AudioX")
45
+ sample_rate = model_config["sample_rate"]
46
+ sample_size = model_config["sample_size"]
47
+ target_fps = model_config["video_fps"]
48
+ seconds_start = 0
49
+ seconds_total = 10
50
+
51
+ model = model.to(device)
52
+
53
+ # for video-to-music generation
54
+ video_path = "video.mp4"
55
+ text_prompt = "Generate music for the video"
56
+ audio_path = None
57
+
58
+ video_tensor = read_video(video_path, seek_time=0, duration=seconds_total, target_fps=target_fps)
59
+ audio_tensor = load_and_process_audio(audio_path, sample_rate, seconds_start, seconds_total)
60
+
61
+ conditioning = [{
62
+ "video_prompt": [video_tensor.unsqueeze(0)],
63
+ "text_prompt": text_prompt,
64
+ "audio_prompt": audio_tensor.unsqueeze(0),
65
+ "seconds_start": seconds_start,
66
+ "seconds_total": seconds_total
67
+ }]
68
+
69
+ # Generate stereo audio
70
+ output = generate_diffusion_cond(
71
+ model,
72
+ steps=250,
73
+ cfg_scale=7,
74
+ conditioning=conditioning,
75
+ sample_size=sample_size,
76
+ sigma_min=0.3,
77
+ sigma_max=500,
78
+ sampler_type="dpmpp-3m-sde",
79
+ device=device
80
+ )
81
+
82
+ # Rearrange audio batch to a single sequence
83
+ output = rearrange(output, "b d n -> d (b n)")
84
+
85
+ # Peak normalize, clip, convert to int16, and save to file
86
+ output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
87
+ torchaudio.save("output.wav", output, sample_rate)
88
+
89
+ if video_path is not None and os.path.exists(video_path):
90
+ merge_video_audio(video_path, "output.wav", "output.mp4", 0, seconds_total)
91
+
92
+ ```
93
+
94
+
95
+
96
+ ## Citation
97
+ If you find our work useful, please consider citing:
98
+
99
+ ```
100
+ @article{tian2025audiox,
101
+ title={AudioX: Diffusion Transformer for Anything-to-Audio Generation},
102
+ author={Tian, Zeyue and Jin, Yizhu and Liu, Zhaoyang and Yuan, Ruibin and Tan, Xu and Chen, Qifeng and Xue, Wei and Guo, Yike},
103
+ journal={arXiv preprint arXiv:2503.10522},
104
+ year={2025}
105
+ }
106
  ```