import torchfrom transformers import Qwen3VLForConditionalGeneration, AutoProcessorfrom peft import PeftModel BASE_ID = "Qwen/Qwen3-VL-2B-Instruct" # <-- the real base modelADAPTER_ID = "Kushtrim/Qwen3-VL-2B-Instruct-Shqip" model = Qwen3VLForConditionalGeneration.from_pretrained( BASE_ID, torch_dtype="auto", device_map="auto", trust_remote_code=True,) model = PeftModel.from_pretrained(model, ADAPTER_ID, token=token) # Optional (often nicer for inference): merge adapter into weightsmodel = model.merge_and_unload() processor = AutoProcessor.from_pretrained( BASE_ID, trust_remote_code=True,) messages = [ { "role": "user", "content": [ { "type": "image", "image": "BU-19970125_34.png", }, {"type": "text", "text": "Transcribe the text in this image."}, ], }] # Preparation for inferenceinputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt")inputs = inputs.to(model.device) # Inference: Generation of the outputgenerated_ids = model.generate(**inputs, max_new_tokens=2048)generated_ids_trimmed = [ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]output_text = processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)print(output_text)