Spaces:
Sleeping
Sleeping
from transformers import TrOCRProcessor, VisionEncoderDecoderModel | |
def plate_rec(img): | |
processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-printed') | |
model = VisionEncoderDecoderModel.from_pretrained('mertbozkurt/trocr-base-printed_license_plates_ocr') | |
pixel_values = processor(images=img, return_tensors="pt").pixel_values | |
generated_ids = model.generate(pixel_values) | |
#generated_ids = model.generate(pixel_values) | |
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] | |
return generated_text | |