Views
No views yet
| Image | Caption / Prompt | Base Model | Fine-Tuned Model |
|---|---|---|---|
![]() | CAT 950 - 100 year anniversary special edition color.... | ### $ ## , ###.## front loader | I love this. |
![]() | The ultimate 'indoor-outdoor' experience My grandfather was a WWII cartographer on the Gothic Line. ... | balcony | I'm so jealous of this place. I've always wanted to build a cabin like this. |
![]() | Made an probiotic seed treatment that makes plants grow 2x faster - early results look promising Bee... | we are working on a new product that will be available in the spring that will be a plant growth enhancer that will be used in soil and hydroponics . | I'm not sure if it's a good idea to buy a lot of these. I'd be worried that it's not working. |
![]() | Elon musk doing a nazi salute at the whitehouse. Unreal... | text : | Elon Musk doing a nazi salute at the whitehouse. Unreal |
![]() | Kowloon walled city this former military base turned into china s tightest city, it was demolished i... | photo credit : courtesy of the artist | Kowloon walled city this former military base turned into china s tightest city, it was demolished in 1994 |
![]() | Mini bulletin board Working on a mini office and made this bulletin board from cork material and cof... | mini office supplies | I love this idea. I've been trying to make a miniature office for a while now. I've been trying to make a miniature office for a while now. I've been trying to make a miniature office for a while now. |
![]() | Santa Cruz Island... | < | <img src="https://www.flickr.com/photos/1000000000000000000/in/album/156551164111 |
![]() | Brown Butter Triple Chocolate Chip Cookies Baked these tonight for a birthday party. Doubled the bat... | cookies | I love this recipe. I made it for a friend's birthday party and it was a huge hit. I love the chocolate chunks and the brown butter. |
![]() | HFF... | < | HFF |
![]() | Popocatepetl Volcano view, Puebla, Mexico... | <img src="https://www.flickr.com/photos/1000000000000000000/in/album/115655154511 |
1!pip install -q -U datasets bitsandbytes peft git+https://github.com/huggingface/transformers.git
2import torch
3from transformers import PaliGemmaForConditionalGeneration, PaliGemmaProcessor, BitsAndBytesConfig
4from peft import PeftModel
5from PIL import Image
6import requests
7
8# 1. Setup IDs
9base_model_id = "google/paligemma2-3b-pt-448"
10adapter_id = "hamzasibous/paligemma_vqav2"
11
12
13bnb_config = BitsAndBytesConfig(
14 load_in_4bit=True,
15 bnb_4bit_quant_type="nf4",
16 bnb_4bit_compute_dtype=torch.bfloat16,
17 bnb_4bit_use_double_quant=True,
18 llm_int8_skip_modules=["vision_tower", "multi_modal_projector", "lm_head"]
19)
20
21device = "cuda"
22model = PaliGemmaForConditionalGeneration.from_pretrained(base_model_id,
23 torch_dtype=torch.bfloat16,
24 quantization_config=bnb_config,
25 low_cpu_mem_usage=True,
26 device_map="auto")
27device = next(model.parameters()).device
28model.to(device)
29processor = PaliGemmaProcessor.from_pretrained(base_model_id)
30
31# Load LoRA Adapter
32model = PeftModel.from_pretrained(model, adapter_id)
33model.eval() # Set to evaluation mode
34
35image_url = "https://preview.redd.it/update-watermelon-sold-v0-snbn9oxn5hng1.jpg?width=1080&crop=smart&auto=webp&s=dd52d355fb847a27a0b4a02e06eee6bc7ea7f55e"
36image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB")
37
38
39caption = "🍉Update: Watermelon Sold A few days ago I asked for melon vendors.\nThe community responded and now the melons are sold.\nThanks you to everyone who responded. And a special thank you to the buyer."
40prompt = "<image>caption text\n" + caption + "\n"
41
42# Generate
43inputs = processor(text=prompt, images=image, return_tensors="pt")
44inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in inputs.items()}
45
46# Disable gradient tracking for inference
47with torch.no_grad():
48 output = model.generate(**inputs, max_new_tokens=50)
49
50print("Caption:" + caption+" Model Output:", processor.decode(output[0], skip_special_tokens=True)[len(prompt):].strip())