Gijs Wijngaard commited on
Commit
9804570
Β·
1 Parent(s): 3d1304c
Files changed (2) hide show
  1. app.py +4 -10
  2. requirements.txt +1 -0
app.py CHANGED
@@ -6,6 +6,8 @@ import soundfile as sf
6
  import torch
7
  from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
8
 
 
 
9
 
10
  MODEL_ID = "microsoft/Phi-4-multimodal-instruct"
11
 
@@ -20,7 +22,7 @@ model = AutoModelForCausalLM.from_pretrained(
20
 
21
  generation_config = GenerationConfig.from_pretrained(MODEL_ID)
22
 
23
-
24
  def run_phi4(audio_path: str, instruction: str, max_tokens: int = 512) -> str:
25
  if not audio_path:
26
  return "Please upload an audio file."
@@ -68,12 +70,4 @@ with gr.Blocks(title="Phi-4 Multimodal Audio Demo") as demo:
68
 
69
 
70
  if __name__ == "__main__":
71
- demo.queue().launch(share=False, ssr_mode=False)
72
-
73
- import gradio as gr
74
-
75
- def greet(name):
76
- return "Hello " + name + "!!"
77
-
78
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
79
- demo.launch()
 
6
  import torch
7
  from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
8
 
9
+ import spaces
10
+
11
 
12
  MODEL_ID = "microsoft/Phi-4-multimodal-instruct"
13
 
 
22
 
23
  generation_config = GenerationConfig.from_pretrained(MODEL_ID)
24
 
25
+ @spaces.GPU
26
  def run_phi4(audio_path: str, instruction: str, max_tokens: int = 512) -> str:
27
  if not audio_path:
28
  return "Please upload an audio file."
 
70
 
71
 
72
  if __name__ == "__main__":
73
+ demo.queue().launch(share=False, ssr_mode=False)
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -4,4 +4,5 @@ transformers>=4.43.0
4
  accelerate>=0.30.0
5
  soundfile>=0.12.1
6
  sentencepiece>=0.1.99
 
7
 
 
4
  accelerate>=0.30.0
5
  soundfile>=0.12.1
6
  sentencepiece>=0.1.99
7
+ spaces
8