Views
No views yet
bfloat16 safetensors weights of Jakelolipopp/Qwen3.5-9B-AltText-v4-LORA applied to base model unsloth/Qwen3.5-9B.unsloth/Qwen3.5-9BJakelolipopp/Qwen3.5-9B-AltText-v4-LORAbfloat161import torch
2from transformers import AutoProcessor, AutoModelForImageTextToText
3from PIL import Image
4
5model_id = "Jakelolipopp/Qwen3.5-9B-AltText-v4-merged"
6processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
7model = AutoModelForImageTextToText.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11 trust_remote_code=True
12)
13
14image = Image.open("example.jpg")
15messages = [
16 {
17 "role": "user",
18 "content": [
19 {"type": "image"},
20 {"type": "text", "text": "Provide detailed alternative text describing this image:"}
21 ]
22 }
23]
24
25text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
26inputs = processor(text=[text], images=[image], return_tensors="pt").to("cuda")
27
28with torch.no_grad():
29 outputs = model.generate(**inputs, max_new_tokens=256)
30
31generated_ids = outputs[:, inputs.input_ids.shape[1]:]
32print(processor.batch_decode(generated_ids, skip_special_tokens=True)[0])