Gijs Wijngaard commited on
Commit
be03629
·
1 Parent(s): 32d55b8
Files changed (2) hide show
  1. app.py +3 -0
  2. requirements.txt +1 -0
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
  from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
3
  import librosa
4
 
 
 
5
 
6
  MODEL_ID = "Qwen/Qwen2-Audio-7B-Instruct"
7
 
@@ -9,6 +11,7 @@ processor = AutoProcessor.from_pretrained(MODEL_ID)
9
  model = Qwen2AudioForConditionalGeneration.from_pretrained(MODEL_ID, device_map="auto")
10
 
11
 
 
12
  def run_qwen2audio(audio_path: str, instruction: str, max_tokens: int = 256) -> str:
13
  if not audio_path:
14
  return "Please upload an audio file."
 
2
  from transformers import Qwen2AudioForConditionalGeneration, AutoProcessor
3
  import librosa
4
 
5
+ import spaces
6
+
7
 
8
  MODEL_ID = "Qwen/Qwen2-Audio-7B-Instruct"
9
 
 
11
  model = Qwen2AudioForConditionalGeneration.from_pretrained(MODEL_ID, device_map="auto")
12
 
13
 
14
+ @spaces.GPU
15
  def run_qwen2audio(audio_path: str, instruction: str, max_tokens: int = 256) -> str:
16
  if not audio_path:
17
  return "Please upload an audio file."
requirements.txt CHANGED
@@ -5,4 +5,5 @@ accelerate>=0.30.0
5
  librosa>=0.10.1
6
  soundfile>=0.12.1
7
  sentencepiece>=0.1.99
 
8
 
 
5
  librosa>=0.10.1
6
  soundfile>=0.12.1
7
  sentencepiece>=0.1.99
8
+ spaces
9