File size: 5,026 Bytes
c50dde6 | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
# 数据
labels = [
'ADE847', 'PC459', 'ADE150', 'PC59', 'VOC20', 'VOC21',
'OV-COCO', 'OV-LVIS', 'Obj365', 'COCO',
'PC60', 'COCO-Obj', 'City', 'PC59', 'ADE', 'COCO-Stf'
]
declip_value = [15.3, 21.4, 36.3, 60.6, 96.6, 81.3,
49.5, 41.5, 20.0, 41.5,
37.9, 38.7, 35.7, 41.6, 23.1, 26.8]
catseg_value = [12.0, 19.0, 31.8, 57.5, 94.6, 77.3,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0]
clipself_value = [0, 0, 0, 0, 0, 0,
44.3, 34.9, 19.5, 40.5,
0, 0, 0, 0, 0, 0]
clearclip_value = [0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
32.6, 33.0, 30.0, 35.9, 16.7, 23.9]
declip_target = 40
# 自动计算归一化值
def normalize_values(target, base_values, method_values):
normalized = []
for base, value in zip(base_values, method_values):
if base == 0 or value == 0:
normalized.append(0)
else:
normalized.append((value / base) * target)
return normalized
declip = normalize_values(declip_target, declip_value, declip_value)
catseg = normalize_values(declip_target, declip_value, catseg_value)
clipself = normalize_values(declip_target, declip_value, clipself_value)
clearclip = normalize_values(declip_target, declip_value, clearclip_value)
# 设置不均匀的角度
group1_angles = np.linspace(0, np.deg2rad(90), 6).tolist()
gap1 = np.deg2rad(50)
group2_angles = np.linspace(np.deg2rad(90) + gap1, np.deg2rad(90) + gap1 + np.deg2rad(60), 4).tolist()
gap2 = np.deg2rad(50)
group3_angles = np.linspace(np.deg2rad(90) + gap1 + np.deg2rad(60) + gap2, np.deg2rad(90) + gap1 + np.deg2rad(60) + gap2 + np.deg2rad(90), 6).tolist()
angles = group1_angles + group2_angles + group3_angles
angles += angles[:1]
# 数据补充,首尾相连
declip = np.concatenate((declip, [declip[0]]))
catseg = np.concatenate((catseg, [catseg[0]]))
clipself = np.concatenate((clipself, [clipself[0]]))
clearclip = np.concatenate((clearclip, [clearclip[0]]))
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
ax.set_ylim(0, 41.5)
# 添加径向为40的圆
r_circle = 41.5
theta = np.linspace(0, 2 * np.pi, 500)
ax.plot(theta, [r_circle] * len(theta), color='black', linestyle='-', linewidth=1.2, alpha=1.0, zorder=0)
ax.set_yticks([10,20,30,40])
# === 只替换下方 DeCLIP 相关的颜色 ===
declip_color = '#8c6d53'
catseg_color = '#91acdd'
clipself_color = '#79b453'
clearclip_color = '#c55a11'
ax.fill(angles, declip, color=declip_color, alpha=0.15, label='DECLIP', zorder=1)
ax.fill(angles, catseg, color=catseg_color, alpha=0.2, label='Previous SOTA CATSeg', zorder=1)
ax.fill(angles, clipself, color=clipself_color, alpha=0.2, label='Previous SOTA CLIPSelf', zorder=1)
ax.fill(angles, clearclip, color=clearclip_color, alpha=0.2, label='Previous SOTA ClearCLIP', zorder=1)
ax.plot(angles, declip, color=declip_color, linewidth=1.5, linestyle='solid', zorder=2)
ax.plot(angles, catseg, color=catseg_color, linewidth=1.5, linestyle='dashed', zorder=2)
ax.plot(angles, clipself, color=clipself_color, linewidth=1.5, linestyle='dashed', zorder=2)
ax.plot(angles, clearclip, color=clearclip_color, linewidth=1.5, linestyle='dashed', zorder=2)
ax.scatter(angles, declip, facecolors=declip_color, s=35, zorder=3, alpha=0.9)
ax.scatter(angles, catseg, facecolors=catseg_color, s=35, zorder=3, alpha=0.9)
ax.scatter(angles, clipself, facecolors=clipself_color, s=35, zorder=3, alpha=0.9)
ax.scatter(angles, clearclip, facecolors=clearclip_color, s=35, zorder=3, alpha=0.9)
# 设置标签
ax.set_xticks(angles[:-1])
ax.set_xticklabels(labels, fontsize=12, ha='center', va='top', color='black')
# for index,(angle, position,value) in enumerate(zip(angles, declip,declip_value)):
# if value > 0:
# if index<6:
# ax.text(angle, position+1, f'{value:.1f}', color=declip_color, fontsize=12,
# ha='left', va='center')
# elif index>=6 and index < 10:
# ax.text(angle, position+0.5, f'{value:.1f}', color=declip_color, fontsize=12,
# ha='right', va='bottom')
# else:
# ax.text(angle, position+1.5, f'{value:.1f}', color=declip_color, fontsize=12,
# ha='left', va='top')
# 图例
legend_elements = [
Patch(facecolor=declip_color, edgecolor=declip_color, label='DeCLIP (Ours)'),
Patch(facecolor=catseg_color, edgecolor=catseg_color, label='CATSeg (OVSS SOTA)'),
Patch(facecolor=clipself_color, edgecolor=clipself_color, label='CLIPSelf (OVD SOTA)'),
Patch(facecolor=clearclip_color, edgecolor=clearclip_color, label='ClearCLIP (ZSSS SOTA)'),
]
ax.legend(
handles=legend_elements,
frameon=True,
fontsize='large',
loc='center',
bbox_to_anchor=(0.26, 0.99),
framealpha=0.5
)
ax.set_yticklabels([])
plt.tight_layout()
plt.savefig('radar_chart.png', dpi=200, bbox_inches='tight', transparent=True)
plt.close() |