GradientDescentMe commited on
Commit
29479bb
·
1 Parent(s): a21f81c

Add Hub download metadata

Browse files
Files changed (3) hide show
  1. README.md +10 -3
  2. README_zh.md +10 -3
  3. config.json +65 -0
README.md CHANGED
@@ -17,7 +17,7 @@ metrics:
17
  - precision
18
  - recall
19
  - f1
20
- library_name: transformers
21
  ---
22
 
23
  # Hiro-Layout: Document Layout Analysis for Patent and Technical PDFs
@@ -153,12 +153,18 @@ The current model artifact is an ONNX export:
153
  layout_model/RT-DETR_25.onnx
154
  ```
155
 
156
- The model can be loaded with ONNXRuntime:
157
 
158
  ```python
 
 
 
159
  import onnxruntime as ort
160
 
161
- session = ort.InferenceSession("layout_model/RT-DETR_25.onnx")
 
 
 
162
  print("inputs:", [i.name for i in session.get_inputs()])
163
  print("outputs:", [o.name for o in session.get_outputs()])
164
  ```
@@ -171,6 +177,7 @@ Use `labels.json` for the 25-class label mapping.
171
  | --- | --- |
172
  | `README.md` | Hugging Face model card in English |
173
  | `README_zh.md` | Chinese model card |
 
174
  | `EVALUATION.md` | Detailed benchmark results derived from the workbook |
175
  | `labels.json` | Machine-readable 25-class label mapping |
176
  | `layout_model/RT-DETR_25.onnx` | ONNX model artifact |
 
17
  - precision
18
  - recall
19
  - f1
20
+ library_name: onnxruntime
21
  ---
22
 
23
  # Hiro-Layout: Document Layout Analysis for Patent and Technical PDFs
 
153
  layout_model/RT-DETR_25.onnx
154
  ```
155
 
156
+ Download the repository from the Hugging Face Hub and load the ONNX model with ONNXRuntime:
157
 
158
  ```python
159
+ from pathlib import Path
160
+
161
+ from huggingface_hub import snapshot_download
162
  import onnxruntime as ort
163
 
164
+ repo_dir = snapshot_download("PatSnap/Hiro-Layout")
165
+ model_path = Path(repo_dir) / "layout_model" / "RT-DETR_25.onnx"
166
+
167
+ session = ort.InferenceSession(str(model_path))
168
  print("inputs:", [i.name for i in session.get_inputs()])
169
  print("outputs:", [o.name for o in session.get_outputs()])
170
  ```
 
177
  | --- | --- |
178
  | `README.md` | Hugging Face model card in English |
179
  | `README_zh.md` | Chinese model card |
180
+ | `config.json` | Model metadata used by Hugging Face Hub tooling and download statistics |
181
  | `EVALUATION.md` | Detailed benchmark results derived from the workbook |
182
  | `labels.json` | Machine-readable 25-class label mapping |
183
  | `layout_model/RT-DETR_25.onnx` | ONNX model artifact |
README_zh.md CHANGED
@@ -17,7 +17,7 @@ metrics:
17
  - precision
18
  - recall
19
  - f1
20
- library_name: transformers
21
  ---
22
 
23
  # Hiro-Layout:面向专利和技术 PDF 的文档版面分析模型
@@ -153,12 +153,18 @@ Hiro-Layout 是一个面向专利和技术 PDF 页面图像的文档版面分析
153
  layout_model/RT-DETR_25.onnx
154
  ```
155
 
156
- 模型可使用 ONNXRuntime 加载:
157
 
158
  ```python
 
 
 
159
  import onnxruntime as ort
160
 
161
- session = ort.InferenceSession("layout_model/RT-DETR_25.onnx")
 
 
 
162
  print("inputs:", [i.name for i in session.get_inputs()])
163
  print("outputs:", [o.name for o in session.get_outputs()])
164
  ```
@@ -171,6 +177,7 @@ print("outputs:", [o.name for o in session.get_outputs()])
171
  | --- | --- |
172
  | `README.md` | 英文 Hugging Face 模型卡 |
173
  | `README_zh.md` | 中文模型卡 |
 
174
  | `EVALUATION.md` | 从 Excel 整理出的详细评测结果 |
175
  | `labels.json` | 机器可读的 25 类标签映射 |
176
  | `layout_model/RT-DETR_25.onnx` | ONNX 模型文件 |
 
17
  - precision
18
  - recall
19
  - f1
20
+ library_name: onnxruntime
21
  ---
22
 
23
  # Hiro-Layout:面向专利和技术 PDF 的文档版面分析模型
 
153
  layout_model/RT-DETR_25.onnx
154
  ```
155
 
156
+ 先从 Hugging Face Hub 下载仓库,再使用 ONNXRuntime 加载模型:
157
 
158
  ```python
159
+ from pathlib import Path
160
+
161
+ from huggingface_hub import snapshot_download
162
  import onnxruntime as ort
163
 
164
+ repo_dir = snapshot_download("PatSnap/Hiro-Layout")
165
+ model_path = Path(repo_dir) / "layout_model" / "RT-DETR_25.onnx"
166
+
167
+ session = ort.InferenceSession(str(model_path))
168
  print("inputs:", [i.name for i in session.get_inputs()])
169
  print("outputs:", [o.name for o in session.get_outputs()])
170
  ```
 
177
  | --- | --- |
178
  | `README.md` | 英文 Hugging Face 模型卡 |
179
  | `README_zh.md` | 中文模型卡 |
180
+ | `config.json` | Hugging Face Hub 工具和下载统计使用的模型元数据 |
181
  | `EVALUATION.md` | 从 Excel 整理出的详细评测结果 |
182
  | `labels.json` | 机器可读的 25 类标签映射 |
183
  | `layout_model/RT-DETR_25.onnx` | ONNX 模型文件 |
config.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "hiro-layout",
3
+ "architectures": [
4
+ "RT-DETR"
5
+ ],
6
+ "task": "object-detection",
7
+ "library_name": "onnxruntime",
8
+ "model_file": "layout_model/RT-DETR_25.onnx",
9
+ "label_file": "labels.json",
10
+ "num_labels": 25,
11
+ "id2label": {
12
+ "0": "graph",
13
+ "1": "drawing",
14
+ "2": "structure diagram",
15
+ "3": "photograph",
16
+ "4": "table",
17
+ "5": "math equation",
18
+ "6": "chemical formula",
19
+ "7": "noise",
20
+ "8": "text",
21
+ "9": "title",
22
+ "10": "section title",
23
+ "11": "page header",
24
+ "12": "page footer",
25
+ "13": "marginal note",
26
+ "14": "caption",
27
+ "15": "figure number",
28
+ "16": "line number",
29
+ "17": "column number",
30
+ "18": "sequence",
31
+ "19": "figure complex",
32
+ "20": "chemical reaction",
33
+ "21": "bibliography",
34
+ "22": "search report",
35
+ "23": "Table of Contents",
36
+ "24": "reference"
37
+ },
38
+ "label2id": {
39
+ "graph": 0,
40
+ "drawing": 1,
41
+ "structure diagram": 2,
42
+ "photograph": 3,
43
+ "table": 4,
44
+ "math equation": 5,
45
+ "chemical formula": 6,
46
+ "noise": 7,
47
+ "text": 8,
48
+ "title": 9,
49
+ "section title": 10,
50
+ "page header": 11,
51
+ "page footer": 12,
52
+ "marginal note": 13,
53
+ "caption": 14,
54
+ "figure number": 15,
55
+ "line number": 16,
56
+ "column number": 17,
57
+ "sequence": 18,
58
+ "figure complex": 19,
59
+ "chemical reaction": 20,
60
+ "bibliography": 21,
61
+ "search report": 22,
62
+ "Table of Contents": 23,
63
+ "reference": 24
64
+ }
65
+ }