SreyanG-NVIDIA commited on
Commit
a37dccc
Β·
verified Β·
1 Parent(s): 4b80ebd

Upload 11 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ static/af3_main_diagram-1.png filter=lfs diff=lfs merge=lfs -text
37
+ static/af3_radial-1.png filter=lfs diff=lfs merge=lfs -text
38
+ static/chat/audio1.mp3 filter=lfs diff=lfs merge=lfs -text
39
+ static/chat/audio2.mp3 filter=lfs diff=lfs merge=lfs -text
40
+ static/logo-no-bg.png filter=lfs diff=lfs merge=lfs -text
41
+ static/voice/voice_2.mp3 filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ import llava
4
+ from peft import PeftModel
5
+ import os
6
+ from huggingface_hub import snapshot_download
7
+
8
+ # ---------------------------------
9
+ # MULTI-TURN MODEL SETUP
10
+ # ---------------------------------
11
+ MODEL_BASE_MULTI = snapshot_download(repo_id="nvidia/audio-flamingo-3-chat")
12
+ model_multi = llava.load(MODEL_BASE_MULTI, model_base=None, devices=[0])
13
+ generation_config_multi = model_multi.default_generation_config
14
+
15
+
16
+ # ---------------------------------
17
+ # MULTI-TURN INFERENCE FUNCTION
18
+ # ---------------------------------
19
+ def multi_turn_chat(user_input, audio_file, history, current_audio):
20
+ try:
21
+ if audio_file is not None:
22
+ current_audio = audio_file # Update state if a new file is uploaded
23
+
24
+ if current_audio is None:
25
+ return history + [("System", "❌ Please upload an audio file before chatting.")], history, current_audio
26
+
27
+ sound = llava.Sound(current_audio)
28
+ prompt = f"<sound>\n{user_input}"
29
+
30
+ response = model_multi.generate_content([sound, prompt], generation_config=generation_config_multi)
31
+
32
+ history.append((user_input, response))
33
+ return history, history, current_audio
34
+ except Exception as e:
35
+ history.append((user_input, f"❌ Error: {str(e)}"))
36
+ return history, history, current_audio
37
+ def speech_prompt_infer(audio_prompt_file):
38
+ try:
39
+ sound = llava.Sound(audio_prompt_file)
40
+ full_prompt = "<sound>"
41
+ response = model_multi.generate_content([sound, full_prompt], generation_config=generation_config_multi)
42
+ return response
43
+ except Exception as e:
44
+ return f"❌ Error: {str(e)}"
45
+ # ---------------------------------
46
+ # INTERFACE
47
+ # ---------------------------------
48
+ with gr.Blocks(css="""
49
+ .gradio-container {
50
+ max-width: 100% !important;
51
+ width: 100% !important;
52
+ margin: 0 !important;
53
+ padding: 0 !important;
54
+ }
55
+ #component-0, .gr-block.gr-box {
56
+ width: 100% !important;
57
+ }
58
+ .gr-block.gr-box, .gr-column, .gr-row {
59
+ padding: 0 !important;
60
+ margin: 0 !important;
61
+ }
62
+ """) as demo:
63
+
64
+ with gr.Column():
65
+ gr.HTML("""
66
+ <div align="center">
67
+ <img src="https://raw.githubusercontent.com/NVIDIA/audio-flamingo/audio_flamingo_3/static/logo-no-bg.png" alt="Audio Flamingo 3 Logo" width="120" style="margin-bottom: 10px;">
68
+ <h2><strong>Audio Flamingo 3</strong></h2>
69
+ <p><em>Advancing Audio Intelligence with Fully Open Large Audio-Language Models</em></p>
70
+ </div>
71
+
72
+ <div align="center" style="margin-top: 10px;">
73
+ <a href="https://arxiv.org/abs/2507.08128">
74
+ <img src="https://img.shields.io/badge/arXiv-2503.03983-AD1C18" alt="arXiv" style="display:inline;">
75
+ </a>
76
+ <a href="https://research.nvidia.com/labs/adlr/AF3/">
77
+ <img src="https://img.shields.io/badge/Demo%20page-228B22" alt="Demo Page" style="display:inline;">
78
+ </a>
79
+ <a href="https://github.com/NVIDIA/audio-flamingo">
80
+ <img src="https://img.shields.io/badge/Github-Audio_Flamingo_3-9C276A" alt="GitHub" style="display:inline;">
81
+ </a>
82
+ <a href="https://github.com/NVIDIA/audio-flamingo/stargazers">
83
+ <img src="https://img.shields.io/github/stars/NVIDIA/audio-flamingo.svg?style=social" alt="GitHub Stars" style="display:inline;">
84
+ </a>
85
+ </div>
86
+ <div align="center" style="display: flex; justify-content: center; margin-top: 10px; flex-wrap: wrap; gap: 5px;">
87
+ <a href="https://huggingface.co/nvidia/audio-flamingo-3">
88
+ <img src="https://img.shields.io/badge/πŸ€—-Checkpoints-ED5A22.svg">
89
+ </a>
90
+ <a href="https://huggingface.co/nvidia/audio-flamingo-3-chat">
91
+ <img src="https://img.shields.io/badge/πŸ€—-Checkpoints_(Chat)-ED5A22.svg">
92
+ </a>
93
+ </div>
94
+ <div align="center" style="display: flex; justify-content: center; margin-top: 10px; flex-wrap: wrap; gap: 5px;">
95
+ <a href="https://huggingface.co/datasets/nvidia/AudioSkills">
96
+ <img src="https://img.shields.io/badge/πŸ€—-Dataset:_AudioSkills--XL-ED5A22.svg">
97
+ </a>
98
+ <a href="https://huggingface.co/datasets/nvidia/LongAudio">
99
+ <img src="https://img.shields.io/badge/πŸ€—-Dataset:_LongAudio--XL-ED5A22.svg">
100
+ </a>
101
+ <a href="https://huggingface.co/datasets/nvidia/AF-Chat">
102
+ <img src="https://img.shields.io/badge/πŸ€—-Dataset:_AF--Chat-ED5A22.svg">
103
+ </a>
104
+ <a href="https://huggingface.co/datasets/nvidia/AF-Think">
105
+ <img src="https://img.shields.io/badge/πŸ€—-Dataset:_AF--Think-ED5A22.svg">
106
+ </a>
107
+ </div>
108
+ """)
109
+ # gr.Markdown("#### NVIDIA (2025)")
110
+
111
+ with gr.Tabs():
112
+ # ---------------- MULTI-TURN CHAT ----------------
113
+ with gr.Tab("πŸ’¬ Multi-Turn Chat"):
114
+ chatbot = gr.Chatbot(label="Audio Chatbot")
115
+ audio_input_multi = gr.Audio(type="filepath", label="Upload or Replace Audio Context")
116
+ user_input_multi = gr.Textbox(label="Your message", placeholder="Ask a question about the audio...", lines=8)
117
+ btn_multi = gr.Button("Send")
118
+ history_state = gr.State([]) # Chat history
119
+ current_audio_state = gr.State(None) # Most recent audio file path
120
+
121
+ btn_multi.click(
122
+ fn=multi_turn_chat,
123
+ inputs=[user_input_multi, audio_input_multi, history_state, current_audio_state],
124
+ outputs=[chatbot, history_state, current_audio_state]
125
+ )
126
+ gr.Examples(
127
+ examples=[
128
+ ["static/chat/audio1.mp3", "This track feels really peaceful and introspective. What elements make it feel so calming and meditative?"],
129
+ ["static/chat/audio2.mp3", "Switching gears, this one is super energetic and synthetic. If I wanted to remix the calming folk piece into something closer to this, what would you suggest?"],
130
+ ],
131
+ inputs=[audio_input_multi, user_input_multi],
132
+ label="πŸ§ͺ Try Examples"
133
+ )
134
+
135
+ with gr.Tab("πŸ—£οΈ Speech Prompt"):
136
+ gr.Markdown("Use your **voice** to talk to the model.")
137
+
138
+ with gr.Row():
139
+ with gr.Column():
140
+ speech_input = gr.Audio(type="filepath", label="Speak or Upload Audio")
141
+ btn_speech = gr.Button("Submit")
142
+ gr.Examples(
143
+ examples=[
144
+ ["static/voice/voice_0.mp3"],
145
+ ["static/voice/voice_1.mp3"],
146
+ ["static/voice/voice_2.mp3"],
147
+ ],
148
+ inputs=speech_input,
149
+ label="πŸ§ͺ Try Examples"
150
+ )
151
+ with gr.Column():
152
+ response_box = gr.Textbox(label="Model Response", lines=15)
153
+
154
+ btn_speech.click(fn=speech_prompt_infer, inputs=speech_input, outputs=response_box)
155
+
156
+
157
+ # ---------------- ABOUT ----------------
158
+ with gr.Tab("πŸ“„ About"):
159
+ gr.Markdown("""
160
+ ### πŸ“š Overview
161
+
162
+ **Audio Flamingo 3** is a fully open state-of-the-art (SOTA) large audio-language model that advances reasoning and understanding across speech, sound, and music. AF3 introduces:
163
+
164
+ (i) AF-Whisper, a unified audio encoder trained using a novel strategy for joint representation learning across all 3 modalities of speech, sound, and music;
165
+
166
+ (ii) flexible, on-demand thinking, allowing the model to do chain-of-thought reasoning before answering;
167
+
168
+ (iii) multi-turn, multi-audio chat;
169
+
170
+ (iv) long audio understanding and reasoning (including speech) up to 10 minutes; and
171
+
172
+ (v) voice-to-voice interaction.
173
+
174
+ To enable these capabilities, we propose several large-scale training datasets curated using novel strategies, including AudioSkills-XL, LongAudio-XL, AF-Think, and AF-Chat, and train AF3 with a novel five-stage curriculum-based training strategy. Trained on only open-source audio data, AF3 achieves new SOTA results on over 20+ (long) audio understanding and reasoning benchmarks, surpassing both open-weight and closed-source models trained on much larger datasets.
175
+
176
+ **Key Features:**
177
+
178
+ πŸ’‘ Audio Flamingo 3 has strong audio, music and speech understanding capabilities.
179
+
180
+ πŸ’‘ Audio Flamingo 3 supports on-demand thinking for chain-of-though reasoning.
181
+
182
+ πŸ’‘ Audio Flamingo 3 supports long audio and speech understanding for audios up to 10 minutes.
183
+
184
+ πŸ’‘ Audio Flamingo 3 can have multi-turn, multi-audio chat with users under complex context.
185
+
186
+ πŸ’‘ Audio Flamingo 3 has voice-to-voice conversation abilities.
187
+
188
+
189
+ """)
190
+
191
+ gr.Markdown("© 2025 NVIDIA | Built with ❀️ using Gradio + PyTorch")
192
+
193
+
194
+ # -----------------------
195
+ # Launch App
196
+ # -----------------------
197
+ if __name__ == "__main__":
198
+ demo.launch(share=True)
static/af3_main_diagram-1.png ADDED

Git LFS Details

  • SHA256: 3908e928f7df50f1860d05d4e31343c44d46550c46bfaff4bb2cf93cea48fd14
  • Pointer size: 131 Bytes
  • Size of remote file: 229 kB
static/af3_radial-1.png ADDED

Git LFS Details

  • SHA256: 5c4f1ede2dd47b45c40996a2827cb34312662f81d92c85d71eec596f9f06631e
  • Pointer size: 131 Bytes
  • Size of remote file: 145 kB
static/chat/.DS_Store ADDED
Binary file (6.15 kB). View file
 
static/chat/audio1.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:927a50999b06065d1e2d728710e54e4205efce7714970f53c1f4e355923034a0
3
+ size 480621
static/chat/audio2.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a58b3ae4e71f0cfb54fbdcb3bb22c710b61dcb6865d3289c4a86054d0648653
3
+ size 481005
static/logo-no-bg.png ADDED

Git LFS Details

  • SHA256: b4868114d109a9939114016c32691405f6d8dfdcdccb29dfce63e52f0b6e9540
  • Pointer size: 131 Bytes
  • Size of remote file: 464 kB
static/voice/.DS_Store ADDED
Binary file (6.15 kB). View file
 
static/voice/voice_0.mp3 ADDED
Binary file (85.4 kB). View file
 
static/voice/voice_1.mp3 ADDED
Binary file (73 kB). View file
 
static/voice/voice_2.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59ed5f5d55bffd6728d26936ec733b8a01c0e5fcbab5f0c859fd37e56198e069
3
+ size 203040