Gijs Wijngaard commited on
Commit
f2c31e0
Β·
1 Parent(s): 20c5650
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -23,7 +23,7 @@ model = AutoModelForCausalLM.from_pretrained(
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."
29
 
@@ -39,7 +39,7 @@ def run_phi4(audio_path: str, instruction: str, max_tokens: int = 512) -> str:
39
 
40
  output_ids = model.generate(
41
  **inputs,
42
- max_new_tokens=int(max_tokens),
43
  generation_config=generation_config,
44
  )
45
  output_ids = output_ids[:, inputs["input_ids"].shape[1]:]
@@ -61,12 +61,11 @@ with gr.Blocks(title="Phi-4 Multimodal Audio Demo") as demo:
61
  "Use <sep> as a separator between the original transcript and the translation."
62
  ),
63
  )
64
- max_tokens = gr.Slider(128, 2000, value=1000, step=64, label="Max Output Tokens")
65
  submit_btn = gr.Button("Run", variant="primary")
66
  with gr.Column():
67
  output_text = gr.Textbox(label="Model Response", lines=14)
68
 
69
- submit_btn.click(run_phi4, [audio_input, instruction, max_tokens], output_text)
70
 
71
 
72
  if __name__ == "__main__":
 
23
  generation_config = GenerationConfig.from_pretrained(MODEL_ID)
24
 
25
  @spaces.GPU
26
+ def run_phi4(audio_path: str, instruction: str) -> str:
27
  if not audio_path:
28
  return "Please upload an audio file."
29
 
 
39
 
40
  output_ids = model.generate(
41
  **inputs,
42
+ max_new_tokens=4096,
43
  generation_config=generation_config,
44
  )
45
  output_ids = output_ids[:, inputs["input_ids"].shape[1]:]
 
61
  "Use <sep> as a separator between the original transcript and the translation."
62
  ),
63
  )
 
64
  submit_btn = gr.Button("Run", variant="primary")
65
  with gr.Column():
66
  output_text = gr.Textbox(label="Model Response", lines=14)
67
 
68
+ submit_btn.click(run_phi4, [audio_input, instruction], output_text)
69
 
70
 
71
  if __name__ == "__main__":