Views
No views yet
https://huggingface.co/yuxinlu1/gemma-4-12B-agentic-fable5-composer2.5-v2-3.5x-tau2-GGUFhttps://huggingface.co/NickyNicky1import torch
2from transformers import AutoProcessor, AutoModelForImageTextToText, AutoModelForCausalLM
3
4M = "tepirale/gemma-4-12B-agentic-fable5-composer2.5-v2-3.5x-tau2-safetensors-yuxinlu1" # la misma carpeta, ahora con embedders
5MA= "tepirale/gemma-4-12B-agentic-fable5-composer2.5-v2-3.5x-tau2-assistant-safetensors-yuxinlu1"
6
7model = AutoModelForImageTextToText.from_pretrained(M, dtype=torch.bfloat16, device_map="auto")
8assistant_model = AutoModelForCausalLM.from_pretrained(MA, dtype=torch.bfloat16, device_map="auto")
9
10processor = AutoProcessor.from_pretrained(M)
11
12
13# Prompt - add image before text
14messages = [
15 {
16 "role": "user", "content": [
17 {"type": "image", "url": "https://raw.githubusercontent.com/google-gemma/cookbook/refs/heads/main/apps/sample-data/GoldenGate.png"},
18 {"type": "text", "text": "What is shown in this image?"}
19 ]
20 }
21]
22
23# Process input
24inputs = processor.apply_chat_template(
25 messages,
26 tokenize=True,
27 return_dict=True,
28 return_tensors="pt",
29 add_generation_prompt=True,
30 enable_thinking=False, # False True
31
32).to(model.device)
33input_len = inputs["input_ids"].shape[-1]
34
35# Generate output
36outputs = model.generate(**inputs, max_new_tokens=512, assistant_model=assistant_model)
37response = processor.decode(outputs[0][input_len:], skip_special_tokens=False)
38
39# Parse output
40processor.parse_response(response)
41
42''' response
43{'content': 'The Golden Gate Bridge, painted in its iconic International Orange, spans San Francisco Bay in California. In the foreground, a lone seagull perches atop a rocky outcrop rising from the water. The Alcatraz Island penitentiary is visible below the bridge.',
44 'role': 'assistant'}
45'''
46