Upload 12 files
Browse files- __init__.py +4 -0
- app.py +11 -4
- model-card.yml +11 -0
- model_index.json +4 -1
- special_tokens_map.json +6 -0
__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .app import MinerUModel
|
2 |
+
from .pipeline import MinerUPipeline
|
3 |
+
|
4 |
+
__version__ = "1.0.0"
|
app.py
CHANGED
@@ -6,15 +6,22 @@ class MinerUModel(PreTrainedModel):
|
|
6 |
def __init__(self, config):
|
7 |
super().__init__(config)
|
8 |
self.config = config
|
|
|
9 |
|
10 |
-
|
11 |
-
def load_model():
|
12 |
from model_loader import MinerUModelLoader
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def forward(self, input_data):
|
16 |
# 实现前向传播逻辑
|
17 |
-
|
18 |
|
19 |
def load_model():
|
20 |
model = MinerUModel.from_pretrained("./")
|
|
|
6 |
def __init__(self, config):
|
7 |
super().__init__(config)
|
8 |
self.config = config
|
9 |
+
self._setup_models()
|
10 |
|
11 |
+
def _setup_models(self):
|
|
|
12 |
from model_loader import MinerUModelLoader
|
13 |
+
self.models = MinerUModelLoader.load_models("./")
|
14 |
+
|
15 |
+
@classmethod
|
16 |
+
def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
|
17 |
+
config = kwargs.pop("config", None)
|
18 |
+
model = cls(config)
|
19 |
+
model._setup_models()
|
20 |
+
return model
|
21 |
|
22 |
def forward(self, input_data):
|
23 |
# 实现前向传播逻辑
|
24 |
+
return self.models["layout"](input_data)
|
25 |
|
26 |
def load_model():
|
27 |
model = MinerUModel.from_pretrained("./")
|
model-card.yml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
- en
|
5 |
+
license: apache-2.0
|
6 |
+
library_name: transformers
|
7 |
+
pipeline_tag: document-conversion
|
8 |
+
tags:
|
9 |
+
- pdf-to-markdown
|
10 |
+
- document-conversion
|
11 |
+
---
|
model_index.json
CHANGED
@@ -3,5 +3,8 @@
|
|
3 |
"architectures": ["MinerUModel"],
|
4 |
"model_type": "mineru",
|
5 |
"transformers_version": "4.28.0",
|
6 |
-
"framework": "pytorch"
|
|
|
|
|
|
|
7 |
}
|
|
|
3 |
"architectures": ["MinerUModel"],
|
4 |
"model_type": "mineru",
|
5 |
"transformers_version": "4.28.0",
|
6 |
+
"framework": "pytorch",
|
7 |
+
"task": "document-conversion",
|
8 |
+
"pipeline_class": "MinerUPipeline",
|
9 |
+
"auto_class": "AutoModelForDocumentConversion"
|
10 |
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"pad_token": "[PAD]",
|
3 |
+
"unk_token": "[UNK]",
|
4 |
+
"cls_token": "[CLS]",
|
5 |
+
"sep_token": "[SEP]"
|
6 |
+
}
|