success_position.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:guesswhat 作者: GuessWhatGame 项目源码 文件源码
def __init__(self, path, games, logger, suffix):
        super(SuccessPosition, self).__init__(path, self.__class__.__name__, suffix)
        x_bin = 7
        y_bin = 7

        success_sum = np.zeros((x_bin+1, y_bin+1))
        total_sum = np.zeros((x_bin+1, y_bin+1))

        for game in games:

            bbox = game.object.bbox
            picture = game.image

            x = int(bbox.x_center / picture.width * x_bin)
            y = int(bbox.y_center / picture.height * y_bin)

            total_sum[x][y] += 1.0

            if game.status == "success":
                success_sum[x][y] += 1.0

        ratio = 1.0 * success_sum / total_sum


        sns.set(style="whitegrid")


        # Draw the heatmap with the mask and correct aspect ratio
        f = sns.heatmap(ratio, robust=True, linewidths=.5, cbar_kws={"label" : "% Success"}, xticklabels=False, yticklabels=False)
        f.set_xlabel("normalized image width", {'size':'14'})
        f.set_ylabel("normalized image height", {'size':'14'})
        f.legend(loc="upper left", fontsize='x-large')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号