| | import json |
| |
|
| | def create_json_dataset(prompt_file, video_file, output_file): |
| | with open(prompt_file, 'r', encoding='utf-8') as f_prompt, \ |
| | open(video_file, 'r', encoding='utf-8') as f_video, \ |
| | open(output_file, 'w', encoding='utf-8') as f_out: |
| | |
| | for caption, video_path in zip(f_prompt, f_video): |
| | |
| | caption = caption.strip() |
| | video_path = video_path.strip() |
| | |
| | |
| | data = { |
| | "video_path": video_path, |
| | "caption": caption |
| | } |
| | json_str = json.dumps(data) |
| | |
| | |
| | f_out.write(json_str + '\n') |
| |
|
| | |
| | prompt_file = '/mnt/workspace/checkpoints/Wild-Heart/Disney-VideoGeneration-Dataset/prompt.txt' |
| | video_file = '/mnt/workspace/checkpoints/Wild-Heart/Disney-VideoGeneration-Dataset/videos.txt' |
| | output_file = 'caption_video.json' |
| |
|
| | create_json_dataset(prompt_file, video_file, output_file) |
| | print(f"JSON文件已生成: {output_file}") |