Update README.md
Browse files
README.md
CHANGED
|
@@ -2,7 +2,29 @@
|
|
| 2 |
license: mit
|
| 3 |
---
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
## Syllabus
|
| 8 |
|
|
|
|
| 2 |
license: mit
|
| 3 |
---
|
| 4 |
|
| 5 |
+
## Quick Start with AutoModel
|
| 6 |
+
|
| 7 |
+
For this image,  start an AutoModel scorer with `transformers==4.31.0`:
|
| 8 |
+
|
| 9 |
+
```python
|
| 10 |
+
import requests
|
| 11 |
+
import torch
|
| 12 |
+
from transformers import AutoModelForCausalLM
|
| 13 |
+
|
| 14 |
+
model = AutoModelForCausalLM.from_pretrained("q-future/one-align", trust_remote_code=True,
|
| 15 |
+
torch_dtype=torch.float16, device_map={"":"cuda:0"})
|
| 16 |
+
|
| 17 |
+
from PIL import Image
|
| 18 |
+
url = "https://raw.githubusercontent.com/Q-Future/Q-Align/main/fig/singapore_flyer.jpg"
|
| 19 |
+
image = Image.open(requests.get(url,stream=True).raw)
|
| 20 |
+
model.score([image], task_="quality", input_="image")
|
| 21 |
+
# task_ : quality | aesthetics; # input_: image | video
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
Result should be 1.911 (in range [1,5], higher is better).
|
| 26 |
+
|
| 27 |
+
From paper: `arxiv.org/abs/2312.17090`.
|
| 28 |
|
| 29 |
## Syllabus
|
| 30 |
|