|
--- |
|
{} |
|
--- |
|
|
|
# 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) |
|
``` |