| """ |
| 示例:使用Qwen2.5-VL原生视频输入进行人格分析 |
| """ |
| import os |
| from model_llm import PersonalityAnalyzer |
| from config import Config |
|
|
| def main(): |
| |
| analyzer = PersonalityAnalyzer() |
| |
| |
| video_path = "/path/to/your/video.mp4" |
| |
| |
| if not os.path.exists(video_path): |
| print(f"错误: 视频文件不存在: {video_path}") |
| print("请替换为实际的视频文件路径") |
| return |
| |
| print("=" * 60) |
| print("使用Qwen原生视频输入进行人格分析") |
| print("=" * 60) |
| |
| |
| print("\n【方法1】使用原生视频输入(use_native_video=True)") |
| result1 = analyzer.predict( |
| video_path=video_path, |
| use_native_video=True, |
| max_frames=20 |
| ) |
| |
| print("\n预测结果:") |
| print(f"外向性 (Extraversion): {result1['scores']['Extraversion']:.3f}") |
| print(f"神经质 (Neuroticism): {result1['scores']['Neuroticism']:.3f}") |
| print(f"宜人性 (Agreeableness): {result1['scores']['Agreeableness']:.3f}") |
| print(f"尽责性 (Conscientiousness): {result1['scores']['Conscientiousness']:.3f}") |
| print(f"开放性 (Openness): {result1['scores']['Openness']:.3f}") |
| print(f"\n推理过程: {result1.get('reasoning', 'N/A')}") |
| |
| |
| print("\n" + "=" * 60) |
| print("【方法2】使用帧提取模式(use_native_video=False)") |
| result2 = analyzer.predict( |
| video_path=video_path, |
| use_native_video=False, |
| max_frames=20, |
| frame_selection="smart" |
| ) |
| |
| print("\n预测结果:") |
| print(f"外向性 (Extraversion): {result2['scores']['Extraversion']:.3f}") |
| print(f"神经质 (Neuroticism): {result2['scores']['Neuroticism']:.3f}") |
| print(f"宜人性 (Agreeableness): {result2['scores']['Agreeableness']:.3f}") |
| print(f"尽责性 (Conscientiousness): {result2['scores']['Conscientiousness']:.3f}") |
| print(f"开放性 (Openness): {result2['scores']['Openness']:.3f}") |
| print(f"\n推理过程: {result2.get('reasoning', 'N/A')}") |
| |
| |
| print("\n" + "=" * 60) |
| print("【方法3】多模态输入(视频 + 文本 + 音频)") |
| |
| |
| text_path = video_path.replace(".mp4", "_transcription.txt") |
| audio_path = video_path.replace(".mp4", ".wav") |
| |
| result3 = analyzer.predict( |
| text=text_path if os.path.exists(text_path) else None, |
| video_path=video_path, |
| audio_path=audio_path if os.path.exists(audio_path) else None, |
| use_native_video=True |
| ) |
| |
| print("\n预测结果:") |
| print(f"外向性 (Extraversion): {result3['scores']['Extraversion']:.3f}") |
| print(f"神经质 (Neuroticism): {result3['scores']['Neuroticism']:.3f}") |
| print(f"宜人性 (Agreeableness): {result3['scores']['Agreeableness']:.3f}") |
| print(f"尽责性 (Conscientiousness): {result3['scores']['Conscientiousness']:.3f}") |
| print(f"开放性 (Openness): {result3['scores']['Openness']:.3f}") |
| print(f"\n推理过程: {result3.get('reasoning', 'N/A')}") |
|
|
| if __name__ == "__main__": |
| main() |
|
|
|
|