Instructions to use dvsth/LEGIT-TrOCR-MT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dvsth/LEGIT-TrOCR-MT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="dvsth/LEGIT-TrOCR-MT", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("dvsth/LEGIT-TrOCR-MT", trust_remote_code=True) model = AutoModel.from_pretrained("dvsth/LEGIT-TrOCR-MT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload model
Browse files- LegibilityModel.py +1 -1
- config.json +3 -0
LegibilityModel.py
CHANGED
|
@@ -19,7 +19,7 @@ class LegibilityModel(PreTrainedModel):
|
|
| 19 |
)
|
| 20 |
|
| 21 |
# choice, img0, img1 are not used by the model, but are passed by the trainer
|
| 22 |
-
def forward(self, img_batch, choice, img0, img1):
|
| 23 |
output = self.model(img_batch)
|
| 24 |
# average the output of the last hidden layer
|
| 25 |
output = output.last_hidden_state.mean(dim=1)
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
# choice, img0, img1 are not used by the model, but are passed by the trainer
|
| 22 |
+
def forward(self, img_batch, choice=None, img0=None, img1=None):
|
| 23 |
output = self.model(img_batch)
|
| 24 |
# average the output of the last hidden layer
|
| 25 |
output = output.last_hidden_state.mean(dim=1)
|
config.json
CHANGED
|
@@ -4,6 +4,9 @@
|
|
| 4 |
"architectures": [
|
| 5 |
"LegibilityModel"
|
| 6 |
],
|
|
|
|
|
|
|
|
|
|
| 7 |
"decoder": {
|
| 8 |
"_name_or_path": "",
|
| 9 |
"activation_dropout": 0.0,
|
|
|
|
| 4 |
"architectures": [
|
| 5 |
"LegibilityModel"
|
| 6 |
],
|
| 7 |
+
"auto_map": {
|
| 8 |
+
"AutoModel": "LegibilityModel.LegibilityModel"
|
| 9 |
+
},
|
| 10 |
"decoder": {
|
| 11 |
"_name_or_path": "",
|
| 12 |
"activation_dropout": 0.0,
|