【深度学习】绘制模型参数量、推理时间以及检测精度mAP的图

绘制模型参数量、推理时间以及检测精度mAP的图

显示效果如下图所示
在这里插入图片描述
代码如下:

import matplotlib.pyplot as plt
import numpy as np

# 定义更新后的函数以绘制性能图表
def plot_model_performance(data):
	# 输入:data矩阵
	# 每一行代表一个模型,第一列为模型参数量(百万),第二列为推理时间,第三列为mAP
    # 检查数据是否为二维且至少有三列
    if data.shape[1] < 3:
        raise ValueError("Data must have at least three columns (model params, inference time, and mAP)")
    # 预定义颜色和标记列表
    colors = ['blue', 'green', 'red', 'purple', 'orange', 'brown', 'cyan', 'magenta', 'yellow', 'black']
    markers = ['o', 's', '^', 'v', '<', '>', 'p', '*', '+', 'x']
    # 创建图表并设置尺寸
    plt.figure(figsize=(20, 6))

    # 第一个图:推理时间 vs. mAP
    plt.subplot(1, 2, 1)
    for idx in range(data.shape[0]):
        plt.scatter(data[idx, 1], data[idx, 2], s=150, color=colors[idx % len(colors)], label=f'Model {idx+1}', marker=markers[idx % len(markers)], edgecolors='black')
    plt.title('Inference Time vs. mAP', fontsize=16, fontweight='bold')
    plt.xlabel('Inference Time (seconds)', fontsize=14)
    plt.ylabel('mAP (%)', fontsize=14)
    plt.ylim(50, 90)
    plt.grid(True, linestyle='--', alpha=0.6)
    plt.legend()

    # 第二个图:模型参数量 vs. mAP
    plt.subplot(1, 2, 2)
    for idx in range(data.shape[0]):
        plt.scatter(data[idx, 0], data[idx, 2], s=150, color=colors[idx % len(colors)], label=f'Model {idx+1}', marker=markers[idx % len(markers)], edgecolors='black')
    plt.title('Model Parameters vs. mAP', fontsize=16, fontweight='bold')
    plt.xlabel('Model Parameters (millions)', fontsize=14)
    plt.ylabel('mAP (%)', fontsize=14)
    plt.ylim(50, 90)
    plt.grid(True, linestyle='--', alpha=0.6)
    plt.legend()

    # 显示图表
    plt.show()


if __name__ == '__main__':
    # 模拟一些数据,第一列为模型参数量(百万),第二列为推理时间,第三列为mAP
    data = np.array([
        [2.5, 0.3, 75],
        [3.5, 0.5, 80],
        [1.5, 0.2, 70],
        [4.0, 0.4, 78],
        [2.8, 0.55, 83]
    ])

    # 调用函数绘制性能图表
    plot_model_performance(data)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值