Error on Hosted Inference API

#4
by faisalrehmanid - opened

I attempted to use this model with a sample image, but I encountered the following error.

Can't load tokenizer using from_pretrained, please update its configuration: <class 'transformers.models.vision_encoder_decoder.configuration_vision_encoder_decoder.VisionEncoderDecoderConfig'>
ss.jpg

Could you please help me to resolve this issue.

Thanks!

Can you provide a snippet of the code that you used to define the processor and model?

Hi, below is the code I've experimented with, and it's now working successfully. However, I encountered some challenges along the way. I would greatly appreciate it if you could include a "How to Use" section in the "Model Card." I'm a newcomer to machine learning, Please inform me if there are areas in my code where I can make improvements.

from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image
import requests

# load image from the IAM database
# url = 'https://fki.tic.heia-fr.ch/static/img/a01-122-02-00.jpg'
image = Image.open('./test.png').convert("RGB")

processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten')
model = VisionEncoderDecoderModel.from_pretrained('DunnBC22/trocr-base-printed_captcha_ocr')
pixel_values = processor(images=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_ids)
print(generated_text)

Right now I'm getting result but with this warning "Could not find image processor class in the image processor config or the model config. Loading based on pattern
matching with the model's feature extractor configuration."

It looks like you have working correctly. I will take your advice about adding a "How to Use" section to the "Model Card" into consideration.

DunnBC22 changed discussion status to closed

Sign up or log in to comment