【工作周报】

内容:

  1. 了解CV领域常用评价标准BLEU、CIDEr、METEOR、ROUGE
  2. 对HMN项目中涉及评分的代码进行分析
  3. 将测试视频的predictions和groundtruth作为输入计算分数
  4. 保存结果到excel文件中

时间:

  • 12.14 ~ 12.20

笔记:

了解CV领域常用评价标准BLEU、CIDEr、METEOR、ROUGE

评价标准之BLEU

首先来看Pn,其计算基于n-gram,现在我们需要将法语翻译成英语,给出一句法语:

Le chat est sur le tapis.

参考翻译有:

  • reference1:The cat is on the mat.
  • reference2:There is a cat on the mat.

而我们的机器翻译模型的输出是:

MT: the the the the the the the.

MT的1-gram只有the这个单词,P1就是MT当中所有在reference中出现过的1-gram数目总和除以MT的1-gram个数,这里就是 7 / 7 = 1 7/7 = 1 7/7=1,这里计算出的 1 叫做precision,Pn的算法只是把单词变成了n-gram。

很明显,precision在遇到上面的例子时,效果非常不好,虽然结果是1,也就是很好的翻译结果,但是MT没有任何意义,因此有了Modified precision,改良后的precision,区别就是为MT中的每个gram设定权重上限;对于上例中的1-gram “the”,在reference1中出现过两次,在reference2中出现过一次,因此限定“the”的分数最大为2,即:

Modified precision = 2/7

注意这里的上限是所有reference中该gram出现的最多次数。

现在回来看公式,N一般最大为4,即最多只统计4-gram的精度,各个n-gram的precision求平均后再经过exp,最后乘以BP乘法因子;乘法因子的作用就是让BLEU倾向于长度较短的翻译,在MT长度大于reference的长度时为1,否则为e的(1-refer_len/MT_len)次方,MT越短BP越大,公式如下:
在这里插入图片描述
更多案例:
在这里插入图片描述

对HMN项目中涉及评分的代码进行分析

HMN项目中涉及评分的代码结构如下:
在这里插入图片描述
在eavl.py文件中,通过导入四种评分的函数来计算模型的分数:

from utils.coco_caption.pycocoevalcap.bleu.bleu import Bleu
from utils.coco_caption.pycocoevalcap.cider.cider import Cider
from utils.coco_caption.pycocoevalcap.meteor.meteor import Meteor
from utils.coco_caption.pycocoevalcap.rouge.rouge import Rougeavg_bleu_score, bleu_score = Bleu(4).compute_score(references, predictions)print('avg_bleu_score == ', avg_bleu_score)avg_cider_score, cider_score = Cider().compute_score(references, predictions)print('avg_cider_score == ', avg_cider_score)avg_meteor_score, meteor_score = Meteor().compute_score(references, predictions)print('avg_meteor_score == ', avg_meteor_score)avg_rouge_score, rouge_score = Rouge().compute_score(references, predictions)print('avg_rouge_score == ', avg_rouge_score)

可以看到这四种计算评分的函数,其参数均为reference,predictions,分别代表groundtruth以及预测结果,其输出由两项,第一项是评估的平均分数,第二项为输入列表的每一个元素的评估分数。

将测试视频的predictions和groundtruth作为输入计算分数

将计算的结果保存到json文件中:

from utils.coco_caption.pycocoevalcap.bleu.bleu import Bleu
from utils.coco_caption.pycocoevalcap.cider.cider import Cider
from utils.coco_caption.pycocoevalcap.meteor.meteor import Meteor
from utils.coco_caption.pycocoevalcap.rouge.rouge import Rouge
import jsonwith open('score_info/original_info.txt', 'r') as f:a = f.readlines()predictions = eval(a[0])references = eval(a[1])avg_bleu_score, bleu_score = Bleu(4).compute_score(references, predictions)avg_cider_score, cider_score = Cider().compute_score(references, predictions)avg_meteor_score, meteor_score = Meteor().compute_score(references, predictions)avg_rouge_score, rouge_score = Rouge().compute_score(references, predictions)with open('score_info/score_bleu.json', 'w') as f1:json.dump(bleu_score, f1)with open('score_info/score_cider.json', 'w') as f1:json.dump(cider_score.tolist(), f1)with open('score_info/score_meteor.json', 'w') as f1:json.dump(meteor_score, f1)with open('score_info/score_rouge.json', 'w') as f1:json.dump(rouge_score.tolist(), f1)print('data written successfully!')

结果如下:
在这里插入图片描述

将结果保存到excel文件中

import json
import xlwtwith open('score_info/original_info.txt', 'r') as f:pre_gt = f.readlines()  # 加载 predictions 和 groundtrutha = eval(pre_gt[0])  # 保存 predictionsc = eval(pre_gt[1])  # 保存 groundtruth
b = ["video6845", "video6521", "video6916", "video6544", "video6671", "video6888", "video6705", "video6769","video6730", "video6563", "video6549", "video6593", "video6933", "video6993", "video6970", "video6979","video6542", "video6552", "video6641", "video6973", "video6741", "video6587", "video6605", "video6710","video6862", "video6985", "video6808", "video6761", "video6596", "video6571", "video6545", "video6952","video6574", "video6823", "video6898", "video6726", "video6558", "video6996", "video6529", "video6718","video6639", "video6585", "video6546", "video6912", "video6750", "video6994", "video6650", "video6713","video6784", "video6689", "video6988", "video6666", "video6514", "video6609", "video6802", "video6897","video6624", "video7001", "video6682", "video6775", "video6679", "video6554", "video6770", "video6711","video6643", "video6714", "video6805", "video6592", "video6620", "video6832", "video6701", "video6732","video6844", "video6555", "video6921", "video6566", "video6910", "video6886", "video6836", "video6520","video6947", "video6661", "video6556", "video6828", "video6972", "video6861", "video6523", "video6885","video6858", "video6875", "video6783", "video6937", "video6739", "video6672", "video6647", "video6756","video6735", "video6685", "video6925", "video6694", "video6588", "video6959", "video6942", "video6906","video6668", "video6659", "video6879", "video6627", "video6601", "video6877", "video6887", "video6835","video6918", "video6538", "video6535", "video6632", "video6853", "video6716", "video6581", "video6797","video6706", "video6757", "video6785", "video6804", "video6883", "video6812", "video6565", "video6602","video6997", "video6759", "video6796", "video6691", "video6787", "video6990", "video6889", "video6519","video6896", "video6830", "video6633", "video6625", "video6920", "video6517", "video6561", "video6874","video6978", "video6790", "video6589", "video6698", "video6852", "video6649", "video6531", "video6622","video6842", "video6557", "video6654", "video6792", "video6697", "video6612", "video6712", "video6693","video6590", "video6618", "video6807", "video6854", "video6667", "video6974", "video6680", "video6767","video6864", "video6999", "video6967", "video6779", "video6788", "video6747", "video6536", "video6690","video6892", "video6894", "video7002", "video6851", "video6946", "video6664", "video6681", "video6709","video6777", "video6736", "video6939", "video6866", "video6725", "video6608", "video6829", "video6599","video6827", "video6884", "video6818", "video6522", "video6849", "video6868", "video6778", "video6960","video6583", "video6722", "video6610", "video6737", "video6657", "video6537", "video6720", "video6953","video6984", "video6846", "video6684", "video6841", "video6763", "video6773", "video6751", "video6594","video6513", "video6708", "video6614", "video6678", "video6865", "video6748", "video6568", "video6526","video6772", "video6791", "video6989", "video6914", "video6968", "video6824", "video6634", "video6573","video6673", "video6936", "video6652", "video6811", "video6817", "video6971", "video6743", "video6901","video6931", "video6721", "video6870", "video6943", "video6809", "video6917", "video6734", "video6964","video6991", "video6938", "video6615", "video6623", "video6847", "video6976", "video7007", "video6752","video6930", "video6934", "video6753", "video6814", "video6771", "video6899", "video6944", "video6525","video6803", "video6882", "video6966", "video6810", "video6822", "video6674", "video6963", "video6755","video6532", "video6820", "video6891", "video6876", "video7005", "video6881", "video6987", "video6895","video6524", "video6758", "video6913", "video6702", "video6826", "video6902", "video6733", "video6837","video6860", "video6927", "video6780", "video6539", "video6819", "video6749", "video6782", "video6534","video6840", "video6924", "video6653", "video7003", "video6941", "video6553", "video6586", "video6688","video6754", "video6617", "video7008", "video6550", "video6600", "video6676", "video6704", "video6528","video6774", "video6584", "video6530", "video6540", "video6595", "video6648", "video6695", "video6613","video6793", "video6948", "video6683", "video6834", "video6729", "video7009", "video6637", "video6635","video6677", "video6738", "video6764", "video6945", "video6905", "video6591", "video6903", "video6543","video6658", "video6551", "video6880", "video6839", "video6578", "video6646", "video7004", "video6929","video6815", "video6760", "video6638", "video6597", "video6576", "video6838", "video6794", "video6848","video6821", "video6687", "video6742", "video6813", "video6719", "video6992", "video6908", "video6800","video6707", "video6855", "video6547", "video6515", "video6603", "video6799", "video6911", "video6869","video6825", "video6645", "video6580", "video6928", "video6669", "video6833", "video6863", "video6776","video6631", "video6670", "video6621", "video6956", "video6577", "video6872", "video6798", "video6871","video6789", "video6516", "video6728", "video6957", "video6982", "video6559", "video6606", "video6893","video6949", "video6995", "video6746", "video6915", "video6656", "video6950", "video6904", "video6806","video6731", "video6655", "video6628", "video6762", "video6958", "video7006", "video6781", "video6548","video6745", "video6983", "video6541", "video6611", "video6961", "video6572", "video6951", "video6630","video6636", "video6607", "video6923", "video6598", "video6575", "video6965", "video6518", "video6981","video6935", "video6642", "video6663", "video6856", "video6696", "video6922", "video6715", "video6926","video6644", "video6567", "video6686", "video6727", "video6786", "video6932", "video6582", "video6723","video6604", "video6977", "video6626", "video6675", "video6859", "video6843", "video6619", "video6740","video6651", "video6700", "video6564", "video6766", "video6703", "video6975", "video6980", "video6816","video6616", "video6692", "video6962", "video6699", "video6867", "video6744", "video6533", "video6986","video6969", "video6850", "video6831", "video6765", "video6724", "video6909", "video6998", "video6579","video6562", "video6890", "video6857", "video6919", "video6907", "video6717", "video7000", "video6900","video6527", "video6665", "video6640", "video6954", "video6801", "video6873", "video6955", "video6629","video6662", "video6878", "video6569", "video6660", "video6768", "video6940", "video6570", "video6560","video6795"]  # 保存 video id
with open('score_info/score_bleu.json') as f1:bleu = json.load(f1)bleu1 = bleu[0]bleu2 = bleu[1]bleu3 = bleu[2]bleu4 = bleu[3]
with open('score_info/score_cider.json') as f1:cider = json.load(f1)
with open('score_info/score_meteor.json') as f1:meteor = json.load(f1)
with open('score_info/score_rouge.json') as f1:rouge = json.load(f1)book = xlwt.Workbook(encoding='utf-8', style_compression=0) #创建excel工作簿
sheet = book.add_sheet('score_info', cell_overwrite_ok=True) #添加页面sheet
col = ('video_id', 'bleu1', 'bleu2', 'bleu3', 'bleu4', 'cider', 'meteor', 'rouge', 'predictions', 'groundtruth') #设定excel表的列#将数据写入表格中
for i in range(0, 497):sheet.write(i, 0, b[i])sheet.write(i, 1, bleu1[i])sheet.write(i, 2, bleu2[i])sheet.write(i, 3, bleu3[i])sheet.write(i, 4, bleu4[i])sheet.write(i, 5, cider[i])sheet.write(i, 6, meteor[i])sheet.write(i, 7, rouge[i])sheet.write(i, 8, a[i])sheet.write(i, 9, c[i])
savepath = 'score_info/excel_info.xls'
book.save(savepath)

最终生成名称为excel_info的xls文件,其内容如下(手动删除掉了groundtruth列之后):
在这里插入图片描述
至此便可以根据评分来对数据进行排序,进而对低分数样本进行归类分析。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/55921.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

日报周报自动生成工具,一句简要描述,自动写出一篇工作日志总结

有了这个工具,再也不用担心每日每周每月的工作日志了,你只需要输入一段简要描述,就可以快速生成完整的工作日志内容,下面我们一起看看效果吧 微信小程序搜索【静静工具箱】免费使用 此工具打开也不需要太多复杂的操作&#xff0…

IT人员的周报应该怎么写

周报对于职场人员一定不陌生,周报既是对自己工作的总结,找到自己工作的问题,也是让老板知道你干了什么,是自己和老板之间进行沟通的桥梁。因为工种的不同,周报的样式也各不相同,作为IT人员,最看…

《花雕学AI》28:革命性的 ChatGPT for SEO——让您的排名飙升 50%!

引言: 如果您想写篇有吸引力的文章,或者您是一个博客和网站的拥有者,那么您一定知道 SEO(搜索引擎优化)的重要性。SEO 可以帮助您提高相应的流量、转化率和收入,但是 SEO 也是一个复杂和耗时的过程&#x…

chatgpt赋能python:Python文字输入的介绍

Python 文字输入的介绍 Python 是一种高级编程语言,具有易学易用、开发效率高等优点。在 Python 中,文字输入是一种非常重要的功能,可以用于很多场景,比如输入用户信息、采集网络数据等。本文将着重介绍 Python 中的文字输入功能…

chatgpt赋能python:如何在Python中输入汉字

如何在Python中输入汉字 在Python中输入汉字可能是许多开发者面临的问题。本文将介绍如何在Python中输入汉字,并提供一些使用Python进行中文处理的技巧。 输入汉字的方法 在Python中输入汉字的方法有许多种。下面我们将介绍其中三种方法。 方法一:使…

Android版ChatGPT正式上线;苹果遭千名开发者索赔10亿美元;阿里加码AR,八天连投两家公司 |极客头条...

「极客头条」—— 技术人员的新闻圈! CSDN 的读者朋友们早上好哇,「极客头条」来啦,快来看今天都有哪些值得我们技术人关注的重要新闻吧。 整理 | 梦依丹 出品 | CSDN(ID:CSDNnews) 一分钟速览新闻点&#…

超简单的五种微博引流方式,教你如何引爆微博流量。

相信很多人对于微博都不陌生,从09年发布至今,已经获取了6亿巨大流量。人们在上面了解实时新闻,了解明星动态等等。但对于微博引流不知道用什么方式,这都很正常的。对于这种内容社区类的平台,需要很强大的运营能力才能保…

Android腾讯微博客户端开发六:给用户加VIP认证以及美化微博显示内容

##之间的内容是代表一个话题,和:之间的是转发这条微博的人,也高亮显示,||代表上一次转发此微博的。url地址也高亮显示。 这个是什么组件啊?是TextView,不会吧?TextView能显示图片吗?肯定能呀。 主要是用到了…

GraphChi之pagerank分析新浪微博用户

GraphChi由卡内基梅隆大学的Aapo Kyrola 博士生开发,是GraphLab项目的一个分支。该框架能够在单机上完成大数据的图计算。 项目地址:https://code.google.com/p/graphchi/ 实例地址:http://code.google.com/p/graphchi/wiki/ExampleApps 其中…

实战新浪微博、腾讯微博的分享功能

算上也是半年前做的,今天翻出来放出来,作为日志记录,也许能帮助一些人。 我做的大概界面是如下图。 主要有两个界面,一个是新浪微博,腾讯微博的分享按钮,一个是他们的绑定情况(其实就是是否授权)。点击微博分享中新浪或腾讯按钮,就进行相应的授权(若没授权),显示微…

微博第三方登录,拿捏了

什么是第三方登录? 用户登录操作不是基于自身建设账号体系,而是基于用户在第三方平台上已有的账号和密码来快速完成登录的过程。下面我列举了几点第三方登录的优点。 极大的简化登录注册的流程。 方便用户快捷登录,降低用户的登录流失率&am…

基于Chrome插件的微博超话自动签到

文章目录 前言一、准备工作二、插件安装1.插件下载2.解压并安装 三、脚本编写(手动获取参数)1.复制脚本2.获取参数3.运行测试 四、脚本编写(自动获取参数)1.复制脚本2.获取参数3.填入参数3.运行测试 总结 前言 不方便使用Chrome插件或对签到结果有通知要求的 请参考 基于Pytho…

微博话题下的数据爬取

1、前言 新浪微博中,一个话题下各个媒体或用户发表在平台发表的信息是舆情研究的一个很重要的数据来源,这里记录一下一个话题下数据的爬取方式,以“#美国疫情#”话题为例。 2、话题下数据爬取 首先参考这篇文章,分析话题下数据爬…

微信微博Facebook们,到底从你身上榨取了什么?

硅谷Live / 实地探访 / 热点探秘 / 深度探讨 如果你不再想从早到晚手机不离身,不再想每小时刷好几遍知乎微博微信 YouTube 和 Instagram,不再想每天被手机分散注意力导致碌碌无为,那这篇文章正是为你准备。 科技公司搜刮你的注意力 在那本著名…

新浪微博PC端登录分析

本来给自己定了个2018的目标,平均每月写两篇文章,现在已经快三月了,第一篇稿子才憋出来,惭愧呀,直入主题吧,今天给大家带来的是新浪微博PC端的模拟登陆。 工具 这次使用的工具是Charles和chrome浏览器&am…

腾讯空间、新浪微博、腾讯微博分享接口

腾讯空间、新浪微博、腾讯微博分享接口。 注意&#xff1a;在网站对接前&#xff0c;请先申请注册好您的QQ登录appid、新浪登录Appkey、腾讯微博appkey。 1、引用JS文件 <script src"http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid&quo…

Android模仿新浪微博(写微博界面)

发布一条新微博接口&#xff1a;http://open.weibo.com/wiki/2/statuses/update 上传图片并发布一条新微博接口&#xff1a;http://open.weibo.com/wiki/2/statuses/upload 1.根据有没有图片来选择相应的接口。 2.根据输入框的改变判断文字数。 3.创建一个girlview显示发送…

android客户端接入新浪、腾讯微博以及人人网

本文原创http://blog.csdn.net/yanbin1079415046&#xff0c;转载请注明出处。 从事android工作也有段时间了&#xff0c;碍于肚子里料不多&#xff0c;一直也没写过什么东西。最近刚好项目中要接入新浪微博&#xff0c;就顺便研究了一下android客户端接入腾讯微博和人人网。由…

【第三方互联】9、新浪微博(sina)授权第三方登录

当我们创建的新浪微博互联应用成功后,我们便可以开始使用该应用来实现新浪微博授权操作 一、获取 App Key 和 App Secret 1、在“我的应用”,点击应用,查看我们创建的应用的基本信息 这样,我们就获取到了 App Key 和 App Secret 2、将 App Key 和 App Secret,以及该应用…

爬取微博上某大v,明星,官微等用户的微博信息的小技巧

通常成功的大门&#xff0c;其实都是虚掩着的 现在大多在爬取微博时&#xff0c;都是采用selenium框架&#xff0c;爬取pc端微博页面&#xff0c;模拟鼠标下拉来解决动态加载的问题&#xff0c;虽然笨拙&#xff0c;但是也能解决问题。今天我给大家推荐个更加好的方法。首先清看…