Make Example Easier To Use
Signed-off-by: tzhouam <tzhouam@connect.ust.hk> Signed-off-by: 齐保元 <qibaoyuan@xiaomi.com>
This commit is contained in:
1 parent
c1a41bde05
commit
14d8c3d95c
5 files changed
+41
-27
No files matched your search
@@ -63,22 +63,30 @@ uv pip install -r requirements.txt
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Run examples (Qwen2.5-omni)
|
## Run examples (Qwen2.5-omni)
|
||||||
Download dataset from seed_tts[https://drive.google.com/file/d/1GlSjVfSHkW3-leKKBlfrjuuTGqQ_xaLP/edit]. To get the prompt, you can:
|
### Multiple Prompts
|
||||||
|
Download dataset from [seed_tts](https://drive.google.com/file/d/1GlSjVfSHkW3-leKKBlfrjuuTGqQ_xaLP/edit). To get the prompt, you can:
|
||||||
```bash
|
```bash
|
||||||
tar -xf <Your Download Path>/seedtts_testset.tar
|
tar -xf <Your Download Path>/seedtts_testset.tar
|
||||||
cp seedtts_testset/en/meta.lst examples/offline_inference/qwen_2_5_omni/meta.lst
|
cp seedtts_testset/en/meta.lst examples/offline_inference/qwen_2_5_omni/meta.lst
|
||||||
python3 examples/offline_inference/qwen_2_5_omni/extract_prompts.py \
|
python3 examples/offline_inference/qwen_2_5_omni/extract_prompts.py \
|
||||||
--input examples/offline_inference/qwen_2_5_omni/meta.lst \
|
--input examples/offline_inference/qwen_2_5_omni/meta.lst \
|
||||||
--output examples/offline_inference/qwen_2_5_omni/top100.txt \
|
--output examples/offline_inference/qwen_2_5_omni/top100.txt \
|
||||||
--topk 100 \
|
--topk 100
|
||||||
--pt-output examples/offline_inference/qwen_2_5_omni/top100.pt
|
|
||||||
```
|
```
|
||||||
Get into the example folder
|
Get into the example folder
|
||||||
```bash
|
```bash
|
||||||
cd examples/offline_inference/qwen_2_5_omni
|
cd examples/offline_inference/qwen_2_5_omni
|
||||||
```
|
```
|
||||||
Modify PYTHONPATH in run.sh as your path of vllm_omni. Then run.
|
Modify PYTHONPATH in run_multiple_prompts.sh as your path of vllm_omni. Then run.
|
||||||
```bash
|
```bash
|
||||||
bash run.sh
|
bash run_multiple_prompts.sh
|
||||||
|
```
|
||||||
|
### Single Prompts
|
||||||
|
Get into the example folder
|
||||||
|
```bash
|
||||||
|
cd examples/offline_inference/qwen_2_5_omni
|
||||||
|
```
|
||||||
|
Modify PYTHONPATH in run_single_prompt.sh as your path of vllm_omni. Then run.
|
||||||
|
```bash
|
||||||
|
bash run_single_prompt.sh
|
||||||
```
|
```
|
||||||
The output audio is saved in ./output_audio
|
|
||||||
@@ -51,9 +51,6 @@ def parse_args():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--prompts", nargs="+", default=None, help="Input text prompts."
|
"--prompts", nargs="+", default=None, help="Input text prompts."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--pt-prompts", type=str, default=None, help="Path to .pt file containing List[str] prompts (overrides --prompts when prompt_type=text)."
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--voice-type", default="default", help="Voice type, e.g., m02, f030, default."
|
"--voice-type", default="default", help="Voice type, e.g., m02, f030, default."
|
||||||
)
|
)
|
||||||
@@ -146,6 +143,12 @@ def parse_args():
|
|||||||
default=False,
|
default=False,
|
||||||
help="Enable writing detailed statistics (default: disabled)",
|
help="Enable writing detailed statistics (default: disabled)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--txt-prompts",
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help="Path to a .txt file with one prompt per line (preferred).",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@@ -153,20 +156,19 @@ def parse_args():
|
|||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
model_name = args.model
|
model_name = args.model
|
||||||
# If pt-prompts provided and prompt_type is text, load and override args.prompts
|
|
||||||
try:
|
try:
|
||||||
if getattr(args, "pt_prompts", None) and args.prompt_type == "text":
|
# Preferred: load from txt file (one prompt per line)
|
||||||
loaded = torch.load(args.pt_prompts)
|
if getattr(args, "txt_prompts", None) and args.prompt_type == "text":
|
||||||
if not isinstance(loaded, list) or (len(loaded) > 0 and not isinstance(loaded[0], str)):
|
with open(args.txt_prompts, "r", encoding="utf-8") as f:
|
||||||
raise ValueError("--pt-prompts must point to a .pt containing List[str]")
|
lines = [ln.strip() for ln in f.readlines()]
|
||||||
args.prompts = loaded
|
args.prompts = [ln for ln in lines if ln != ""]
|
||||||
print(f"[Info] Loaded {len(args.prompts)} prompts from {args.pt_prompts}")
|
print(f"[Info] Loaded {len(args.prompts)} prompts from {args.txt_prompts}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[Error] Failed to load pt-prompts: {e}")
|
print(f"[Error] Failed to load prompts: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if args.prompts is None:
|
if args.prompts is None:
|
||||||
raise ValueError("No prompts provided. Use --prompts ... or --pt-prompts <file.pt> (with --prompt_type text)")
|
raise ValueError("No prompts provided. Use --prompts ... or --txt-prompts <file.txt> (with --prompt_type text)")
|
||||||
omni_llm = OmniLLM(
|
omni_llm = OmniLLM(
|
||||||
model=model_name,
|
model=model_name,
|
||||||
log_stats=args.enable_stats,
|
log_stats=args.enable_stats,
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ def extract_prompt(line: str) -> Optional[str]:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--input", "-i", required=True, help="输入 .lst 文件路径")
|
parser.add_argument("--input", "-i", required=True, help="Input .lst file path")
|
||||||
parser.add_argument("--output", "-o", required=True, help="输出文件路径")
|
parser.add_argument("--output", "-o", required=True, help="Output file path")
|
||||||
parser.add_argument("--topk", "-k", type=int, default=100, help="提取前 K 个 prompt(默认 100)")
|
parser.add_argument("--topk", "-k", type=int, default=100, help="Extract the top K prompts (default: 100)")
|
||||||
parser.add_argument("--pt-output", "-p", type=str, default=None, help="可选:输出 .pt 文件路径(默认与 --output 同名 .pt)")
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
prompts = []
|
prompts = []
|
||||||
@@ -37,10 +36,6 @@ def main() -> None:
|
|||||||
for p in prompts:
|
for p in prompts:
|
||||||
f.write(p + "\n")
|
f.write(p + "\n")
|
||||||
|
|
||||||
# 另存为 PyTorch 序列化的 .pt,内容为字符串列表
|
|
||||||
pt_path = args.pt_output if args.pt_output else os.path.splitext(args.output)[0] + ".pt"
|
|
||||||
torch.save(prompts, pt_path)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
+1
-1
@@ -6,4 +6,4 @@ python end2end.py --model Qwen/Qwen2.5-Omni-7B \
|
|||||||
--output-wav output_audio \
|
--output-wav output_audio \
|
||||||
--prompt_type text \
|
--prompt_type text \
|
||||||
--init-sleep-seconds 0 \
|
--init-sleep-seconds 0 \
|
||||||
--pt-prompts <Your_Prompt_File>.pt
|
--txt-prompts top100.txt
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export PYTHONPATH=/path/to/vllm-omni:$PYTHONPATH
|
||||||
|
python end2end.py --model Qwen/Qwen2.5-Omni-7B \
|
||||||
|
--voice-type "m02" \
|
||||||
|
--dit-ckpt none \
|
||||||
|
--bigvgan-ckpt none \
|
||||||
|
--output-wav output_audio \
|
||||||
|
--prompt_type text \
|
||||||
|
--init-sleep-seconds 0 \
|
||||||
|
--prompts "Explain the system architecture for a scalable audio generation pipeline. Answer in 15 words."
|
||||||
Reference in new issue
Block a user