import torchfrom PIL import Imagefrom transformers import AutoProcessor, AutoModelForImageTextToText repo = "ai4bharat/BrailleQwen-2B"processor = AutoProcessor.from_pretrained(repo)model = AutoModelForImageTextToText.from_pretrained(repo, dtype=torch.bfloat16, device_map="auto") image = Image.open("braille.png").convert("RGB")messages = [{ "role": "user", "content": [ {"type": "image"}, {"type": "text", "text": "Transcribe the Braille characters shown in this image."}, ],}]prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = processor(text=[prompt], images=[[image]], return_tensors="pt").to(model.device) with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=256, do_sample=False)text = processor.tokenizer.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()print(text)