big_ai / grace_eval.py
xiehuangbao1122's picture
Update grace_eval.py
22197f0 verified
raw
history blame
1.13 kB
import matplotlib.pyplot as plt
def compute_sample_scores(results, prompt):
# 示例评分 - 实际应用中可以用更复杂的评估逻辑
return {
"sd_v1_5": {"G": 4, "R": 4, "A": 4, "E": 3},
"openjourney_v4": {"G": 3, "R": 4, "A": 5, "E": 3},
"ldm_256": {"G": 2, "R": 3, "A": 3, "E": 5}
}
def plot_radar(scores_dict, out_path="radar.png"):
categories = list(scores_dict.values())[0].keys()
N = len(categories)
fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
for model, scores in scores_dict.items():
values = list(scores.values())
values += values[:1] # 闭合雷达图
angles = [n / float(N) * 2 * 3.14159 for n in range(N)]
angles += angles[:1]
ax.plot(angles, values, linewidth=1, linestyle='solid', label=model)
ax.fill(angles, values, alpha=0.1)
ax.set_xticks(angles[:-1])
ax.set_xticklabels(categories)
ax.set_title("GRACE 评估雷达图 (CPU模式)", size=12, y=1.1)
ax.legend(loc='upper right')
plt.savefig(out_path, bbox_inches='tight')
plt.close()