Views
No views yet
pip install unsloth1from unsloth import FastVisionModel
2
3model, tokenizer = FastVisionModel.from_pretrained("awaliuddin/unsloth_finetune", load_in_4bit=True)
4FastVisionModel.for_inference(model)1from PIL import Image
2
3image = Image.open("path/to/your/image.jpg") # Replace with your image path
4instruction = "You are an expert radiographer. Describe accurately what you see in this image."
5messages = [ {"role": "user", "content": [ {"type": "image"}, {"type": "text", "text": instruction} ]} ]
6
7input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True) inputs = tokenizer(image, input_text, add_special_tokens=False, return_tensors="pt").to("cuda")
8
9from transformers import TextStreamer
10
11text_streamer = TextStreamer(tokenizer, skip_prompt=True) _ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=128, use_cache=True, temperature=1.5, min_p=0.1)