sampling.py 文件源码

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

项目:evaluation_tools 作者: JSALT-Rosetta 项目源码 文件源码
def get_nb_caption_per_img(n, selected_captions): 
    """
    Get image id from audio caption file names that were selected by their speakers
    Choose images that have at least n captions per image
    ----------
    n : int, 
        desired number of caption per image
    selected_captions : list of string, 
        list of caption file names selected by their speakers
    """

    counter_nb_caption=Counter()

    for cap in selected_captions: 
        #get image id 
        ImgID = cap.split('_')[-0]
        # add a count 
        counter_nb_caption[ImgID]+=1

    #choose img_id that have a count of n
    d=dict((k, v) for k, v in counter_nb_caption.items() if v == n)

    ImgID_selected=d.keys()

    return(ImgID_selected)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号