1 parent
779aa534ba
commit
a2dd5feb80
2 files changed
+54
-26
No files matched your search
@@ -1,23 +1,36 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install ffmpeg -y
|
||||||
|
|
||||||
# Move to repo root (script lives in .buildkite/scripts/)
|
# Move to repo root (script lives in .buildkite/scripts/)
|
||||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
cd "${ROOT_DIR}"
|
cd "${ROOT_DIR}"
|
||||||
|
|
||||||
python3 -m pip install --upgrade pip uv
|
UV_INSTALL_DIR="${ROOT_DIR}/.local/bin"
|
||||||
BOOTSTRAP_PY="$(command -v python3)"
|
case ":${PATH}:" in
|
||||||
UV_BIN=("${BOOTSTRAP_PY}" -m uv)
|
*":${UV_INSTALL_DIR}:"*) ;;
|
||||||
|
*) export PATH="${UV_INSTALL_DIR}:${PATH}" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if ! command -v uv >/dev/null 2>&1; then
|
||||||
|
mkdir -p "${UV_INSTALL_DIR}"
|
||||||
|
curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="${UV_INSTALL_DIR}" sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
UV_BIN=(uv)
|
||||||
|
|
||||||
"${UV_BIN[@]}" python install 3.12
|
"${UV_BIN[@]}" python install 3.12
|
||||||
"${UV_BIN[@]}" venv --python 3.12 .venv
|
"${UV_BIN[@]}" venv --python 3.12 .venv
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
|
|
||||||
"${UV_BIN[@]}" pip install --python .venv/bin/python vllm==0.11.0 --torch-backend=auto
|
"${UV_BIN[@]}" pip install -e .
|
||||||
"${UV_BIN[@]}" pip install --python .venv/bin/python -e .
|
"${UV_BIN[@]}" pip install vllm==0.11.0 --torch-backend=auto
|
||||||
|
|
||||||
EXAMPLE_DIR="examples/offline_inference/qwen2_5_omni"
|
EXAMPLE_DIR="examples/offline_inference/qwen2_5_omni"
|
||||||
cd "${EXAMPLE_DIR}"
|
cd "${EXAMPLE_DIR}"
|
||||||
|
|
||||||
bash run_single_prompt.sh
|
python end2end.py --output-wav output_audio \
|
||||||
|
--query-type use_audio_in_video \
|
||||||
|
--no-save-results
|
||||||
@@ -5,6 +5,7 @@ This example shows how to use vLLM-omni for running offline inference
|
|||||||
with the correct prompt format on Qwen2.5-Omni
|
with the correct prompt format on Qwen2.5-Omni
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
@@ -195,35 +196,43 @@ def main(args):
|
|||||||
|
|
||||||
omni_outputs = omni_llm.generate(prompts, sampling_params_list)
|
omni_outputs = omni_llm.generate(prompts, sampling_params_list)
|
||||||
|
|
||||||
# Determine output directory: prefer --output-dir; fallback to --output-wav
|
output_dir = None
|
||||||
output_dir = args.output_dir if getattr(args, "output_dir", None) else args.output_wav
|
if args.save_results:
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
# Determine output directory: prefer --output-dir; fallback to --output-wav
|
||||||
|
output_dir = args.output_dir if getattr(args, "output_dir", None) else args.output_wav
|
||||||
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
for stage_outputs in omni_outputs:
|
for stage_outputs in omni_outputs:
|
||||||
if stage_outputs.final_output_type == "text":
|
if stage_outputs.final_output_type == "text":
|
||||||
for output in stage_outputs.request_output:
|
for output in stage_outputs.request_output:
|
||||||
request_id = int(output.request_id)
|
request_id = int(output.request_id)
|
||||||
text_output = output.outputs[0].text
|
text_output = output.outputs[0].text
|
||||||
# Save aligned text file per request
|
if args.save_results:
|
||||||
prompt_text = prompts[request_id]["prompt"]
|
# Save aligned text file per request
|
||||||
out_txt = os.path.join(output_dir, f"{request_id:05d}.txt")
|
prompt_text = prompts[request_id]["prompt"]
|
||||||
lines = []
|
out_txt = os.path.join(output_dir, f"{request_id:05d}.txt")
|
||||||
lines.append("Prompt:\n")
|
lines = []
|
||||||
lines.append(str(prompt_text) + "\n")
|
lines.append("Prompt:\n")
|
||||||
lines.append("vllm_text_output:\n")
|
lines.append(str(prompt_text) + "\n")
|
||||||
lines.append(str(text_output).strip() + "\n")
|
lines.append("vllm_text_output:\n")
|
||||||
try:
|
lines.append(str(text_output).strip() + "\n")
|
||||||
with open(out_txt, "w", encoding="utf-8") as f:
|
try:
|
||||||
f.writelines(lines)
|
with open(out_txt, "w", encoding="utf-8") as f:
|
||||||
except Exception as e:
|
f.writelines(lines)
|
||||||
print(f"[Warn] Failed writing text file {out_txt}: {e}")
|
except Exception as e:
|
||||||
print(f"Request ID: {request_id}, Text saved to {out_txt}")
|
print(f"[Warn] Failed writing text file {out_txt}: {e}")
|
||||||
|
print(f"Request ID: {request_id}, Text saved to {out_txt}")
|
||||||
|
else:
|
||||||
|
print(f"Request ID: {request_id}, Text output:\n{text_output}")
|
||||||
elif stage_outputs.final_output_type == "audio":
|
elif stage_outputs.final_output_type == "audio":
|
||||||
for output in stage_outputs.request_output:
|
for output in stage_outputs.request_output:
|
||||||
request_id = int(output.request_id)
|
request_id = int(output.request_id)
|
||||||
audio_tensor = output.multimodal_output["audio"]
|
audio_tensor = output.multimodal_output["audio"]
|
||||||
output_wav = os.path.join(output_dir, f"output_{output.request_id}.wav")
|
if args.save_results:
|
||||||
sf.write(output_wav, audio_tensor.detach().cpu().numpy(), samplerate=24000)
|
output_wav = os.path.join(output_dir, f"output_{output.request_id}.wav")
|
||||||
print(f"Request ID: {request_id}, Saved audio to {output_wav}")
|
sf.write(output_wav, audio_tensor.detach().cpu().numpy(), samplerate=24000)
|
||||||
|
print(f"Request ID: {request_id}, Saved audio to {output_wav}")
|
||||||
|
else:
|
||||||
|
print(f"Request ID: {request_id}, Received audio output (not saved).")
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
@@ -266,6 +275,12 @@ def parse_args():
|
|||||||
default=65536,
|
default=65536,
|
||||||
help="Threshold for using shared memory in bytes (default: 65536)",
|
help="Threshold for using shared memory in bytes (default: 65536)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--save-results",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
default=True,
|
||||||
|
help="Save text/audio outputs to files (default: enabled). Use --no-save-results to disable.",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--output-wav",
|
"--output-wav",
|
||||||
default="output_audio",
|
default="output_audio",
|
||||||
|
|||||||
Reference in new issue
Block a user