Instructions to use Humayoun/TrOCRTraining2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Humayoun/TrOCRTraining2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Humayoun/TrOCRTraining2")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("Humayoun/TrOCRTraining2") model = AutoModelForImageTextToText.from_pretrained("Humayoun/TrOCRTraining2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Humayoun/TrOCRTraining2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Humayoun/TrOCRTraining2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Humayoun/TrOCRTraining2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Humayoun/TrOCRTraining2
- SGLang
How to use Humayoun/TrOCRTraining2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Humayoun/TrOCRTraining2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Humayoun/TrOCRTraining2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Humayoun/TrOCRTraining2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Humayoun/TrOCRTraining2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Humayoun/TrOCRTraining2 with Docker Model Runner:
docker model run hf.co/Humayoun/TrOCRTraining2
| tags: | |
| - generated_from_trainer | |
| model-index: | |
| - name: TrOCRTraining2 | |
| results: [] | |
| <!-- This model card has been generated automatically according to the information the Trainer had access to. You | |
| should probably proofread and complete it, then remove this comment. --> | |
| # TrOCRTraining2 | |
| This model is a fine-tuned version of [microsoft/trocr-base-stage1](https://huggingface.co/microsoft/trocr-base-stage1) on an unknown dataset. | |
| It achieves the following results on the evaluation set: | |
| - Loss: 0.4589 | |
| - Cer: 0.0115 | |
| ## Model description | |
| More information needed | |
| ## Intended uses & limitations | |
| More information needed | |
| ## Training and evaluation data | |
| More information needed | |
| ## Training procedure | |
| ### Training hyperparameters | |
| The following hyperparameters were used during training: | |
| - learning_rate: 5e-05 | |
| - train_batch_size: 8 | |
| - eval_batch_size: 8 | |
| - seed: 42 | |
| - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08 | |
| - lr_scheduler_type: linear | |
| - num_epochs: 15 | |
| ### Training results | |
| | Training Loss | Epoch | Step | Validation Loss | Cer | | |
| |:-------------:|:-----:|:----:|:---------------:|:------:| | |
| | 0.7331 | 1.06 | 50 | 0.8204 | 0.1775 | | |
| | 0.4908 | 2.13 | 100 | 0.5457 | 0.0229 | | |
| | 0.4912 | 3.19 | 150 | 0.5845 | 0.0229 | | |
| | 0.4713 | 4.26 | 200 | 0.5433 | 0.0137 | | |
| | 0.4435 | 5.32 | 250 | 0.4988 | 0.0126 | | |
| | 0.4152 | 6.38 | 300 | 0.5058 | 0.0137 | | |
| | 0.3026 | 7.45 | 350 | 0.4947 | 0.0126 | | |
| | 0.4133 | 8.51 | 400 | 0.4988 | 0.0115 | | |
| | 0.4029 | 9.57 | 450 | 0.4906 | 0.0160 | | |
| | 0.3439 | 10.64 | 500 | 0.4790 | 0.0160 | | |
| | 0.3386 | 11.7 | 550 | 0.4661 | 0.0103 | | |
| | 0.3511 | 12.77 | 600 | 0.4617 | 0.0115 | | |
| | 0.374 | 13.83 | 650 | 0.4629 | 0.0149 | | |
| | 0.3357 | 14.89 | 700 | 0.4589 | 0.0115 | | |
| ### Framework versions | |
| - Transformers 4.28.1 | |
| - Pytorch 2.0.0+cu118 | |
| - Datasets 2.12.0 | |
| - Tokenizers 0.13.3 | |