File size: 1,255 Bytes
34a44be 359509e 8d1637c 34a44be 8d1637c 34a44be a250831 34a44be a250831 34a44be a250831 34a44be a250831 34a44be a250831 34a44be a250831 34a44be a250831 34a44be a250831 34a44be a250831 34a44be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
---
{}
---
# ViPer: Metric
GitHub: https://github.com/sogandstorme/ViPer_Personalization
## Example
```bash
git clone https://github.com/sogandstorme/ViPer_Personalization.git
cd ViPer_Personalization
```
```python
from metric import (
set_device,
load_context_images,
initialize_processor_and_model,
calculate_score
)
# Ensure that the number of liked and disliked images are the same
negative_image_paths = [
"disliked/0.png",
"disliked/1.png",
"disliked/2.png",
"disliked/3.png",
"disliked/4.png",
"disliked/5.png",
"disliked/6.png",
"disliked/7.png",
"disliked/8.png",
]
positive_image_paths = [
"liked/0.png",
"liked/1.png",
"liked/2.png",
"liked/3.png",
"liked/4.png",
"liked/5.png",
"liked/6.png",
"liked/7.png",
"liked/8.png",
]
# Specify the address of the query image
query_image = "query.png"
device = set_device("cuda:0")
# Initialize processor and model
device = set_device("cuda:0")
context_images = load_context_images(negative_image_paths, positive_image_paths)
processor, model = initialize_processor_and_model(device)
# Calculate and print score
score = calculate_score(processor, model, context_images, query_image)
print(score)
``` |