File size: 1,208 Bytes
baa93b6
 
03b8479
baa93b6
 
 
 
 
03b8479
 
baa93b6
03b8479
baa93b6
 
 
03b8479
 
 
baa93b6
 
22197f0
baa93b6
 
22197f0
 
baa93b6
 
 
22197f0
baa93b6
 
22197f0
baa93b6
 
 
 
 
 
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
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
import io

DIMENSIONS = ["Generalization", "Relevance", "Artistry", "Efficiency"]

def compute_sample_scores(results, prompt):
    """模拟评分 - 实际项目应替换为真实评估逻辑"""
    return {
        "sd_v1_5": [4, 4, 4, 3],
        "openjourney_v4": [3, 4, 5, 3],
        "ldm_256": [2, 3, 3, 5]
    }

def plot_radar(scores_dict, out_path="radar.png"):
    fig = plt.figure(figsize=(8, 8))
    ax = fig.add_subplot(111, polar=True)
    
    angles = np.linspace(0, 2*np.pi, len(DIMENSIONS), endpoint=False)
    angles = np.concatenate((angles, [angles[0]]))
    
    for model, scores in scores_dict.items():
        data = np.concatenate((scores, [scores[0]]))
        ax.plot(angles, data, linewidth=2, linestyle='solid', label=model)
        ax.fill(angles, data, alpha=0.1)
    
    ax.set_thetagrids(angles[:-1] * 180/np.pi, DIMENSIONS)
    ax.set_title("GRACE Evaluation Radar", size=14, pad=20)
    ax.legend(loc='upper right')
    
    buf = io.BytesIO()
    plt.savefig(buf, format='png', bbox_inches='tight')
    plt.close()
    buf.seek(0)
    return Image.open(buf)