Update README.md
Browse files
README.md
CHANGED
|
@@ -3,5 +3,37 @@ language:
|
|
| 3 |
- ar
|
| 4 |
---
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
- ar
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# Peacock
|
| 7 |
+
Peacock is InstructBLIP model using AraLLaMA as language model. Peacock was introduced in the paper [Peacock: A Family of Arabic Multimodal Large Language Models and Benchmarks]((https://arxiv.org/abs/2403.01031)).
|
| 8 |
+
|
| 9 |
+
# How to use
|
| 10 |
+
|
| 11 |
+
Usage is as follows:
|
| 12 |
+
|
| 13 |
+
```
|
| 14 |
+
from transformers import InstructBlipProcessor, InstructBlipForConditionalGeneration
|
| 15 |
+
import torch
|
| 16 |
+
from PIL import Image
|
| 17 |
+
import requests
|
| 18 |
+
model = InstructBlipForConditionalGeneration.from_pretrained("Fakhraddin/InstructBlip-AraLLaMA")
|
| 19 |
+
processor = InstructBlipProcessor.from_pretrained("Fakhraddin/InstructBlip-AraLLaMA")
|
| 20 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 21 |
+
model.to(device)
|
| 22 |
+
url = "https://raw.githubusercontent.com/salesforce/LAVIS/main/docs/_static/Confusing-Pictures.jpg"
|
| 23 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
| 24 |
+
prompt = "What is unusual about this image?"
|
| 25 |
+
inputs = processor(images=image, text=prompt, return_tensors="pt").to(device)
|
| 26 |
+
outputs = model.generate(
|
| 27 |
+
**inputs,
|
| 28 |
+
do_sample=False,
|
| 29 |
+
num_beams=5,
|
| 30 |
+
max_length=256,
|
| 31 |
+
min_length=1,
|
| 32 |
+
top_p=0.9,
|
| 33 |
+
repetition_penalty=1.5,
|
| 34 |
+
length_penalty=1.0,
|
| 35 |
+
temperature=1,
|
| 36 |
+
)
|
| 37 |
+
generated_text = processor.batch_decode(outputs, skip_special_tokens=True)[0].strip()
|
| 38 |
+
print(generated_text)
|
| 39 |
+
```
|