diff --git a/examples/offline_inference/qwen_2_5_omni/README.md b/examples/offline_inference/qwen_2_5_omni/README.md index 770c5e169..08c5c3400 100644 --- a/examples/offline_inference/qwen_2_5_omni/README.md +++ b/examples/offline_inference/qwen_2_5_omni/README.md @@ -63,7 +63,16 @@ uv pip install -r requirements.txt ``` ## 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: +```bash +tar -xf /seedtts_testset.tar +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 \ + --input examples/offline_inference/qwen_2_5_omni/meta.lst \ + --output examples/offline_inference/qwen_2_5_omni/top100.txt \ + --topk 100 \ + --pt-output examples/offline_inference/qwen_2_5_omni/top100.pt +``` Get into the example folder ```bash cd examples/offline_inference/qwen_2_5_omni diff --git a/examples/offline_inference/qwen_2_5_omni/extract_prompts.py b/examples/offline_inference/qwen_2_5_omni/extract_prompts.py new file mode 100644 index 000000000..a1bc7a78f --- /dev/null +++ b/examples/offline_inference/qwen_2_5_omni/extract_prompts.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +import argparse +from typing import Optional +import os +import torch + + +def extract_prompt(line: str) -> Optional[str]: + # 提取第一个 '|' 与第二个 '|' 之间的内容 + i = line.find('|') + if i == -1: + return None + j = line.find('|', i + 1) + if j == -1: + return None + return line[i + 1:j].strip() + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--input", "-i", required=True, help="输入 .lst 文件路径") + parser.add_argument("--output", "-o", required=True, help="输出文件路径") + parser.add_argument("--topk", "-k", type=int, default=100, help="提取前 K 个 prompt(默认 100)") + parser.add_argument("--pt-output", "-p", type=str, default=None, help="可选:输出 .pt 文件路径(默认与 --output 同名 .pt)") + args = parser.parse_args() + + prompts = [] + with open(args.input, "r", encoding="utf-8", errors="ignore") as f: + for line in f: + if len(prompts) >= args.topk: + break + p = extract_prompt(line.rstrip("\n")) + if p: + prompts.append(p) + + with open(args.output, "w", encoding="utf-8") as f: + for p in prompts: + 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__": + main() + + diff --git a/examples/offline_inference/qwen_2_5_omni/top100.pt b/examples/offline_inference/qwen_2_5_omni/top100.pt deleted file mode 100644 index 017c60ac8..000000000 Binary files a/examples/offline_inference/qwen_2_5_omni/top100.pt and /dev/null differ