Skip to content

Commit

Permalink
Merge pull request #228 from NexaAI/weili/dev
Browse files Browse the repository at this point in the history
[WIP][qwen2audio example] temporarily fix the nonsense output issue of qwen2audio
  • Loading branch information
zhiyuan8 authored Nov 11, 2024
2 parents 2b75762 + 4974ca8 commit 2ffbe20
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions nexa/gguf/nexa_inference_audio_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ def _load_model(self):
0x7FFFFFFF if self.n_gpu_layers == -1 else self.n_gpu_layers
) # 0x7FFFFFFF is INT32 max, will be auto set to all layers

self.context = audio_lm_cpp.init_context(
ctypes.byref(self.ctx_params), is_qwen=self.is_qwen
)
if not self.context:
raise RuntimeError("Failed to load audio language model")
logging.debug("Model loaded successfully")
# self.context = audio_lm_cpp.init_context(
# ctypes.byref(self.ctx_params), is_qwen=self.is_qwen
# )
# if not self.context:
# raise RuntimeError("Failed to load audio language model")
# logging.debug("Model loaded successfully")
except Exception as e:
logging.error(f"Error loading model: {e}")
raise
Expand Down Expand Up @@ -190,6 +190,13 @@ def inference(self, audio_path: str, prompt: str = "") -> str:
self.ctx_params.file = ctypes.c_char_p(audio_path.encode("utf-8"))
self.ctx_params.prompt = ctypes.c_char_p(prompt.encode("utf-8"))

self.context = audio_lm_cpp.init_context(
ctypes.byref(self.ctx_params), is_qwen=self.is_qwen
)
if not self.context:
raise RuntimeError("Failed to load audio language model")
logging.debug("Model loaded successfully")

response = audio_lm_cpp.process_full(
self.context, ctypes.byref(self.ctx_params), is_qwen=self.is_qwen
)
Expand Down

0 comments on commit 2ffbe20

Please sign in to comment.