-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
74 lines (54 loc) · 1.94 KB
/
example.py
File metadata and controls
74 lines (54 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
简单的使用示例
"""
import asyncio
import sys
from pathlib import Path
# 添加项目路径
sys.path.append(str(Path(__file__).parent))
from src.utils import setup_logging
from src.processors import ProcessorManager
from src.models import ModelManager
async def example_process_single_file():
"""处理单个文件的示例"""
setup_logging()
# 初始化处理器管理器
processor_manager = ProcessorManager()
# 示例文件路径(请根据实际情况修改)
test_file = Path("data/input/example.txt")
if test_file.exists():
result = await processor_manager.process_file(test_file)
print("处理结果:", result)
else:
print(f"文件不存在: {test_file}")
async def example_process_image():
"""处理图片的示例"""
setup_logging()
# 初始化模型管理器
model_manager = ModelManager()
# 示例图片路径(请根据实际情况修改)
image_file = Path("data/input/example.jpg")
if image_file.exists():
result = await model_manager.process_image(image_file)
print("图片处理结果:", result)
else:
print(f"图片不存在: {image_file}")
def example_get_supported_formats():
"""获取支持格式的示例"""
processor_manager = ProcessorManager()
formats = processor_manager.get_supported_formats()
print("支持的文件格式:")
for processor_name, format_list in formats.items():
print(f"{processor_name}: {format_list}")
if __name__ == "__main__":
print("多模态数据处理示例")
print("=" * 30)
# 示例1: 获取支持的格式
print("\n1. 支持的文件格式:")
example_get_supported_formats()
# 示例2: 处理单个文件
print("\n2. 处理单个文件:")
asyncio.run(example_process_single_file())
# 示例3: 处理图片
print("\n3. 处理图片文件:")
asyncio.run(example_process_image())