Gijs Wijngaard
commited on
Commit
Β·
5bb5fa5
1
Parent(s):
5af88f3
init
Browse files
app.py
CHANGED
|
@@ -3,18 +3,17 @@ import gradio as gr
|
|
| 3 |
|
| 4 |
import soundfile as sf
|
| 5 |
import torch
|
| 6 |
-
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
model_path = "microsoft/Phi-4-multimodal-instruct"
|
| 12 |
-
device = f"{infer_device()}:0"
|
| 13 |
|
| 14 |
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
|
| 15 |
model = AutoModelForCausalLM.from_pretrained(
|
| 16 |
model_path,
|
| 17 |
-
device_map=
|
| 18 |
dtype=torch.float16,
|
| 19 |
trust_remote_code=True,
|
| 20 |
_attn_implementation="flash_attention_2",
|
|
@@ -23,7 +22,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 23 |
model.load_adapter(
|
| 24 |
model_path,
|
| 25 |
adapter_name="speech",
|
| 26 |
-
device_map=
|
| 27 |
adapter_kwargs={"subfolder": 'speech-lora'}
|
| 28 |
)
|
| 29 |
model.set_adapter("speech")
|
|
|
|
| 3 |
|
| 4 |
import soundfile as sf
|
| 5 |
import torch
|
| 6 |
+
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
model_path = "microsoft/Phi-4-multimodal-instruct"
|
|
|
|
| 12 |
|
| 13 |
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
|
| 14 |
model = AutoModelForCausalLM.from_pretrained(
|
| 15 |
model_path,
|
| 16 |
+
device_map="auto",
|
| 17 |
dtype=torch.float16,
|
| 18 |
trust_remote_code=True,
|
| 19 |
_attn_implementation="flash_attention_2",
|
|
|
|
| 22 |
model.load_adapter(
|
| 23 |
model_path,
|
| 24 |
adapter_name="speech",
|
| 25 |
+
device_map="auto",
|
| 26 |
adapter_kwargs={"subfolder": 'speech-lora'}
|
| 27 |
)
|
| 28 |
model.set_adapter("speech")
|