|
| 1 | +# Asset Vectorization Tool |
| 2 | + |
| 3 | +用于将Asset表中的SVG资源向量化并存储到向量数据库的工具。 |
| 4 | + |
| 5 | +## 功能 |
| 6 | + |
| 7 | +- 批量处理Asset表中的SVG格式资源 |
| 8 | +- 从Kodo对象存储下载图片文件 |
| 9 | +- 调用算法服务生成向量数据 |
| 10 | +- 支持干跑模式测试 |
| 11 | +- 完整的进度跟踪和错误处理 |
| 12 | + |
| 13 | +## 使用方法 |
| 14 | + |
| 15 | +```bash |
| 16 | +# 干跑模式 - 只显示会处理哪些资源,不实际向量化 |
| 17 | +./simple-run.sh -dry-run -verbose -batch=10 |
| 18 | + |
| 19 | +# 处理前100条记录 |
| 20 | +./simple-run.sh -verbose -batch=20 -end=100 |
| 21 | + |
| 22 | +# 处理指定范围的记录 |
| 23 | +./simple-run.sh -verbose -batch=50 -start=100 -end=200 |
| 24 | + |
| 25 | +# 处理所有SVG资源 |
| 26 | +./simple-run.sh -verbose -batch=50 |
| 27 | +``` |
| 28 | + |
| 29 | +## 参数说明 |
| 30 | + |
| 31 | +| 参数 | 说明 | 默认值 | |
| 32 | +|------|------|--------| |
| 33 | +| `-batch` | 批处理大小 | 50 | |
| 34 | +| `-start` | 起始ID | 0 | |
| 35 | +| `-end` | 结束ID (0表示无限制) | 0 | |
| 36 | +| `-dry-run` | 干跑模式,不实际向量化 | false | |
| 37 | +| `-verbose` | 详细输出 | false | |
| 38 | + |
| 39 | +## 环境要求 |
| 40 | + |
| 41 | +工具会自动从 `../../.env` 文件加载以下环境变量: |
| 42 | + |
| 43 | +- `GOP_SPX_DSN` - 数据库连接字符串 |
| 44 | +- `ALGORITHM_ENDPOINT` - 算法服务端点 |
| 45 | +- `KODO_AK` / `KODO_SK` - Kodo访问凭证 |
| 46 | +- `KODO_BUCKET` / `KODO_BUCKET_REGION` - Kodo存储桶配置 |
| 47 | + |
| 48 | +## 输出示例 |
| 49 | + |
| 50 | +``` |
| 51 | +🚀 Asset Vectorization Tool |
| 52 | +✅ Environment variables loaded: |
| 53 | +📍 Database: root:root@tcp(xxx)... |
| 54 | +📍 Algorithm: http://localhost:5000 |
| 55 | +
|
| 56 | +🎯 Starting vectorization... |
| 57 | +📊 Processing asset resources... |
| 58 | + Found 520 total assets to process |
| 59 | + [DRY RUN] Asset 1769: red-shirted man (found 4 images) |
| 60 | + - First image: kodo://goplus-builder-usercontent-test/files/xxx |
| 61 | + ✅ Asset 2412: Ani_Alice (vectorized with kodo://xxx) |
| 62 | +
|
| 63 | +🎉 Asset vectorization completed! |
| 64 | +Results: Total: 520, Success: 450, Failed: 70, Duration: 2m30s |
| 65 | +``` |
| 66 | + |
| 67 | +## 注意事项 |
| 68 | + |
| 69 | +- 工具只处理SVG格式的资源文件 |
| 70 | +- 确保算法服务正常运行在配置的端点 |
| 71 | +- 大批量处理时建议使用较小的batch size避免内存问题 |
| 72 | +- 使用干跑模式验证配置后再进行实际向量化 |
0 commit comments