Update README.md
Browse files
README.md
CHANGED
@@ -16,26 +16,23 @@ library_name: peft
|
|
16 |
|
17 |
## How to Get Started with the Model
|
18 |
```python
|
|
|
|
|
|
|
19 |
import torch
|
20 |
-
from peft import PeftModel, PeftConfig
|
21 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
model = PeftModel.from_pretrained(base_model, "pdufour/Llama-3.2-11B-Vision-WebSight")
|
29 |
-
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
text = "Generate code for a web page that looks exactly like this"
|
34 |
|
35 |
-
inputs = processor(images=image_path, text=text, return_tensors="pt")
|
36 |
-
|
37 |
-
# Generate response
|
38 |
-
outputs = model.generate(**inputs)
|
39 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
40 |
```
|
41 |
|
|
|
16 |
|
17 |
## How to Get Started with the Model
|
18 |
```python
|
19 |
+
from transformers import AutoModelForVision2Seq, AutoTokenizer, AutoProcessor
|
20 |
+
from peft import PeftModel
|
21 |
+
from PIL import Image
|
22 |
import torch
|
|
|
|
|
23 |
|
24 |
+
model = PeftModel.from_pretrained(
|
25 |
+
AutoModelForVision2Seq.from_pretrained("meta-llama/Llama-3.2-11B-Vision-Instruct", device_map="auto", load_in_4bit=True),
|
26 |
+
"pdufour/Llama-3.2-11B-Vision-WebSight"
|
27 |
+
)
|
28 |
+
tokenizer = AutoTokenizer.from_pretrained("pdufour/Llama-3.2-11B-Vision-WebSight")
|
29 |
+
processor = AutoProcessor.from_pretrained("meta-llama/Llama-3.2-11B-Vision-Instruct")
|
30 |
|
31 |
+
inputs = processor(text="Generate code for a web page that looks exactly like this. <|image|>", images=Image.open("fashion.jpg"), return_tensors="pt").to(model.device)
|
|
|
|
|
32 |
|
33 |
+
with torch.no_grad():
|
34 |
+
outputs = model.generate(input_ids=inputs['input_ids'], max_new_tokens=4096, do_sample=True, temperature=0.7, top_p=0.9)
|
|
|
35 |
|
|
|
|
|
|
|
|
|
36 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
37 |
```
|
38 |
|