|
|
--- |
|
|
tags: |
|
|
- biochemistry |
|
|
- chemistry |
|
|
- OCR |
|
|
license: mpl-2.0 |
|
|
datasets: |
|
|
- maxall4/biochemistry-ocr |
|
|
language: |
|
|
- en |
|
|
--- |
|
|
# TrOCR Biochemistry |
|
|
This is a finetuned model based on the [TrOCR](https://huggingface.co/docs/transformers/en/model_doc/trocr) model. |
|
|
It was finetuned on the [biochemistry-ocr dataset](https://huggingface.co/datasets/maxall4/biochemistry-ocr) to make the model better at recognizing text like Kcat/Km, Ki, Km, chemical names and greek symbols. |
|
|
|
|
|
## Usage |
|
|
|
|
|
This model can be used just lile TrOCR just change the model name to `maxall4/TrOCR-biochemistry`. You can find the TrOCR docs [here](https://huggingface.co/docs/transformers/en/model_doc/trocr). |
|
|
|
|
|
Example: |
|
|
```python |
|
|
from transformers import TrOCRProcessor, VisionEncoderDecoderModel |
|
|
import requests |
|
|
from PIL import Image |
|
|
|
|
|
processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten") |
|
|
model = VisionEncoderDecoderModel.from_pretrained("maxall4/TrOCR-biochemistry") |
|
|
|
|
|
image = Image.open('kikcat.png').convert("RGB") |
|
|
|
|
|
pixel_values = processor(image, return_tensors="pt").pixel_values |
|
|
generated_ids = model.generate(pixel_values) |
|
|
|
|
|
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] |
|
|
print(generated_text) |
|
|
``` |