Views
No views yet
1!pip install transformers pillow torch unsloth datasets
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from PIL import Image
4
5# Load tokenizer and model
6tokenizer = AutoTokenizer.from_pretrained("BSAtlas/model-name")
7model = AutoModelForCausalLM.from_pretrained("BSAtlas/model-name")
8
9# Example usage for text input
10input_text = "Describe the contents of an image."
11inputs = tokenizer(input_text, return_tensors="pt")
12outputs = model.generate(**inputs)
13print(tokenizer.decode(outputs[0], skip_special_tokens=True))
14
15# Example usage for multimodal input
16image = Image.open("path/to/image.jpg")
17image_features = model.process_image(image) # Replace with your image processing logic
18inputs = tokenizer("Analyze this image:", return_tensors="pt")
19outputs = model.generate(**inputs, image_features=image_features)
20print(tokenizer.decode(outputs[0], skip_special_tokens=True))