File size: 1,106 Bytes
81dc3a6
 
 
 
 
 
 
62b998d
 
 
 
 
 
 
c301de7
62b998d
 
 
81dc3a6
 
49eb64d
 
81dc3a6
 
49eb64d
 
 
 
 
 
 
 
 
 
 
81dc3a6
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
from PIL import Image, UnidentifiedImageError
from utils import *


def get_evaluation_data(ds):
    evaluation_data = []
    for i in range(len(ds)):
        img = ds[i]["image"]
        thumbnail_img = img.copy()
        thumbnail_img.thumbnail((256, 256))
        evaluation_data.append({
            "id": ds[i]["ex_id"],
            "image_thumbnail": image_to_base64(thumbnail_img),
            "image_full": image_to_base64(img),
            "image_full_url": "https://visionlmsftw-vibe-testing-images.hf.space/image/" + str(i),
            "prompt": ds[i]["prompt"],
            "category": ds[i]["category"]
        })
    return evaluation_data

def get_model_names(ds_results):
    models = list(set(ds_results['model_id']))
    return models

def get_responses(ds_results):
    responses = {}
    
    for model in set(ds_results['model_id']):
        model_responses = [
            row["model_response"]
            for row in ds_results
            if row["model_id"] == model
        ]
        responses[model] = {i: resp for i, resp in enumerate(model_responses)}
    
    return responses