Views
No views yet
1
2# Example Usage
3from transformers import BlipProcessor, BlipForQuestionAnswering
4from PIL import Image
5import requests
6
7model_id = "suc1dalspinach/fine_blip_gym"
8
9# 2. Load the processor and model
10processor = BlipProcessor.from_pretrained(model_id)
11model = BlipForQuestionAnswering.from_pretrained(model_id)
12
13# 3. Prepare your input (image and question)
14image = Image.open("path/to/your/image.jpg").convert("RGB")
15
16question = "What is the name of the gym equipment?"
17
18# 4. Process the inputs
19inputs = processor(images=image, text=question, return_tensors="pt", truncation=True)
20
21# 5. Generate the answer
22out = model.generate(**inputs)
23
24# 6. Decode and print the answer
25answer = processor.decode(out[0], skip_special_tokens=True)
26print(f"Question: {question}")
27print(f"Answer: {answer}")