感觉没必要用 buckets 了, 直接 datasets 就可以满足需求
Browse files- .gitignore +1 -0
- main.py +18 -1
.gitignore
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
__pycache__/
|
| 2 |
.venv/
|
|
|
|
| 3 |
*.pdf
|
| 4 |
!戚蓼生序本石头记.pdf
|
| 5 |
echodict_local.duckdb
|
|
|
|
| 1 |
__pycache__/
|
| 2 |
.venv/
|
| 3 |
+
buckets_hlm/
|
| 4 |
*.pdf
|
| 5 |
!戚蓼生序本石头记.pdf
|
| 6 |
echodict_local.duckdb
|
main.py
CHANGED
|
@@ -5,6 +5,21 @@ uv venv --python 3.12 --seed --clear
|
|
| 5 |
|
| 6 |
duckdb.exe 运行后 CALL start_ui();
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"""
|
| 9 |
|
| 10 |
import duckdb
|
|
@@ -12,6 +27,8 @@ import duckdb
|
|
| 12 |
|
| 13 |
if __name__ == '__main__':
|
| 14 |
|
|
|
|
|
|
|
| 15 |
con = duckdb.connect('typsthlm.duckdb')
|
| 16 |
|
| 17 |
# image_path 仅存储如 'images/img_001.jpg' 这样的相对路径
|
|
@@ -38,7 +55,7 @@ if __name__ == '__main__':
|
|
| 38 |
# 插入数据(存入相对路径)
|
| 39 |
con.execute("""
|
| 40 |
INSERT INTO image_annotations (image_path, md5, boxs) VALUES (
|
| 41 |
-
'
|
| 42 |
'1234567890abcdef1234567890abcdef1',
|
| 43 |
[{"charText": '天', 'isPicText': false, 'pic_path': '', 'charPoly': {'x1': 0, 'y1': 0, 'x2': 100, 'y2': 100, 'x3': 200, 'y3': 200, 'x4': 300, 'y4': 300}}]
|
| 44 |
)
|
|
|
|
| 5 |
|
| 6 |
duckdb.exe 运行后 CALL start_ui();
|
| 7 |
|
| 8 |
+
用 .duckdb 作为本地的“动态引擎“ CRUD 用 .parquet 作为你的“静态发布与同步格式 Sync ,这是目前处理数据清洗标注与 Hugging Face 交互的业界标准范式
|
| 9 |
+
|
| 10 |
+
uv tool install hf
|
| 11 |
+
|
| 12 |
+
hf sync ./buckets_hlm hf://buckets/echodict/buckets_hlm
|
| 13 |
+
它的默认行为其实就是同步“文件夹内的内容”,而不是把整个文件夹连同外层目录名一起同步过去
|
| 14 |
+
建议在命令最后加上 --dry-run 参数。它不会真的上传,而是打印出一份清单告诉你哪些文件会被上传,确认无误后再去掉 --dry-run 正式执行
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Hugging Face 的 Dataset 仓库(以及 Model/Space 仓库)提供了非常方便的 API 来遍历目录并流式读取图片文件。
|
| 18 |
+
你可以使用官方的 huggingface_hub 库中的 HfFileSystem 或 list_repo_tree 等功能,这让云端的文件操作就像在本地操作一样自然。
|
| 19 |
+
感觉没必要用 buckets 了, 直接 datasets 就可以满足需求
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
"""
|
| 24 |
|
| 25 |
import duckdb
|
|
|
|
| 27 |
|
| 28 |
if __name__ == '__main__':
|
| 29 |
|
| 30 |
+
|
| 31 |
+
|
| 32 |
con = duckdb.connect('typsthlm.duckdb')
|
| 33 |
|
| 34 |
# image_path 仅存储如 'images/img_001.jpg' 这样的相对路径
|
|
|
|
| 55 |
# 插入数据(存入相对路径)
|
| 56 |
con.execute("""
|
| 57 |
INSERT INTO image_annotations (image_path, md5, boxs) VALUES (
|
| 58 |
+
'data/ch01/out2/SWX0005_00001_00001.webp',
|
| 59 |
'1234567890abcdef1234567890abcdef1',
|
| 60 |
[{"charText": '天', 'isPicText': false, 'pic_path': '', 'charPoly': {'x1': 0, 'y1': 0, 'x2': 100, 'y2': 100, 'x3': 200, 'y3': 200, 'x4': 300, 'y4': 300}}]
|
| 61 |
)
|