利用xlwt写excel并进行单元格的合并

1.写入行列值

import xlwt
# 创建一个workbook 设置编码
workbook = xlwt.Workbook(encoding='utf-8')
# 创建一个worksheet
worksheet = workbook.add_sheet('My Worksheet')# 写入excel
# 参数对应 行, 列, 值
worksheet.write(1, 0, label = 'this is test')# 保存
workbook.save('Excel_test.xls')

            

2.更改样式

import xlwtworkbook = xlwt.Workbook(encoding = 'ascii')
worksheet = workbook.add_sheet('My Worksheet')
style = xlwt.XFStyle() # 初始化样式
font = xlwt.Font() # 为样式创建字体
font.name = 'Times New Roman'
font.bold = True # 黑体
font.underline = True # 下划线
font.italic = True # 斜体字
style.font = font # 设定样式
worksheet.write(0, 0, 'Unformatted value') # 不带样式的写入worksheet.write(1, 0, 'Formatted value', style) # 带样式的写入workbook.save('formatting.xls') # 保存文件

3.设置单元格宽度

import xlwtworkbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
worksheet.write(0, 0,'My Cell Contents')# 设置单元格宽度
worksheet.col(0).width = 5555
workbook.save('cell_width.xls')

4.输入日期进表格

import xlwt
import datetime
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
style = xlwt.XFStyle()
style.num_format_str = 'M/D/YY' # Other options: D-MMM-YY, D-MMM, MMM-YY, h:mm, h:mm:ss, h:mm, h:mm:ss, M/D/YY h:mm, mm:ss, [h]:mm:ss, mm:ss.0
worksheet.write(0, 0, datetime.datetime.now(), style)
workbook.save('Excel_Workbook.xls')

5.合并行列单元格

import xlwt
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
#             #  0 0 行 0 3 列
worksheet.write_merge(0, 0, 0, 3, 'First Merge') # Merges row 0's columns 0 through 3.
font = xlwt.Font() # Create Font
font.bold = True # Set font to Bold
style = xlwt.XFStyle() # Create Style
style.font = font # Add Bold Font to Style#  1 2 行 0 3 列
worksheet.write_merge(1, 2, 0, 3, 'Second Merge', style)
workbook.save('Excel_Workbook.xls')

6.设置单元格对齐方式

import xlwt
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
alignment = xlwt.Alignment() # Create Alignment
alignment.horz = xlwt.Alignment.HORZ_CENTER # May be: HORZ_GENERAL, HORZ_LEFT, HORZ_CENTER, HORZ_RIGHT, HORZ_FILLED, HORZ_JUSTIFIED, HORZ_CENTER_ACROSS_SEL, HORZ_DISTRIBUTED
alignment.vert = xlwt.Alignment.VERT_CENTER # May be: VERT_TOP, VERT_CENTER, VERT_BOTTOM, VERT_JUSTIFIED, VERT_DISTRIBUTED
style = xlwt.XFStyle() # Create Style
style.alignment = alignment # Add Alignment to Style
worksheet.write(0, 0, 'Cell Contents', style)
worksheet.col(0).width = 5555
workbook.save('Excel_Workbook.xls')

7.为单元格设置背景色

import xlwt
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
pattern = xlwt.Pattern() # Create the Pattern
pattern.pattern = xlwt.Pattern.SOLID_PATTERN # May be: NO_PATTERN, SOLID_PATTERN, or 0x00 through 0x12
pattern.pattern_fore_colour = 5 # May be: 8 through 63. 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta, 7 = Cyan, 16 = Maroon, 17 = Dark Green, 18 = Dark Blue, 19 = Dark Yellow , almost brown), 20 = Dark Magenta, 21 = Teal, 22 = Light Gray, 23 = Dark Gray, the list goes on...
style = xlwt.XFStyle() # Create the Pattern
style.pattern = pattern # Add Pattern to Style
worksheet.write(0, 0, 'Cell Contents', style)
workbook.save('Excel_Workbook.xls')

8.为单元格设置边框

import xlwtworkbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
borders = xlwt.Borders()  # Create Borders
borders.left = xlwt.Borders.DASHED
# DASHED虚线
# NO_LINE没有
# THIN实线# May be: NO_LINE, THIN, MEDIUM, DASHED, DOTTED, THICK, DOUBLE, HAIR, MEDIUM_DASHED, THIN_DASH_DOTTED, MEDIUM_DASH_DOTTED, THIN_DASH_DOT_DOTTED, MEDIUM_DASH_DOT_DOTTED, SLANTED_MEDIUM_DASH_DOTTED, or 0x00 through 0x0D.
borders.right = xlwt.Borders.DASHED
borders.top = xlwt.Borders.DASHED
borders.bottom = xlwt.Borders.DASHED
borders.left_colour = 0x40
borders.right_colour = 0x40
borders.top_colour = 0x40
borders.bottom_colour = 0x40
style = xlwt.XFStyle()  # Create Style
style.borders = borders  # Add Borders to Style
worksheet.write(0, 0, 'Cell Contents', style)
workbook.save('Excel_Workbook.xls')

案例1:

import xlwt
from xlwt import Workbookdef simulate_data():cell_id_sets = [{(0, 1), (0, 0), (0, 5), (0, 4), (0, 3), (0, 2)}, {(7, 4), (7, 3), (7, 5)}, {(3, 0), (2, 0), (5, 0), (4, 0)}, {(2, 3), (3, 3), (4, 3), (5, 3)}, {(1, 0)}, {(6, 0)}, {(7, 0)}, {(1, 1)}, {(2, 1)}, {(3, 1)}, {(4, 1)}, {(5, 1)}, {(6, 1)}, {(7, 1)}, {(1, 2)}, {(2, 2)}, {(3, 2)}, {(4, 2)}, {(5, 2)}, {(6, 2)}, {(7, 2)}, {(1, 3)}, {(6, 3)}, {(1, 4)}, {(2, 4)}, {(3, 4)}, {(4, 4)}, {(5, 4)}, {(6, 4)}, {(1, 5)}, {(2, 5)}, {(3, 5)}, {(4, 5)}, {(5, 5)}, {(6, 5)}, set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set(), set()]x_grids = [25, 187, 326, 434, 584, 713, 819]y_grids = [12, 42, 108, 142, 176, 210, 244, 278, 312]ids = 35rst = []for id in range(ids):if len(cell_id_sets[id]) == 0:continueif len(cell_id_sets[id]) == 1:cell = {}cell_row, cell_col = list(cell_id_sets[id])[0]cell["id"] = idcell["row_start"] = cell_row  # 结构坐标cell["col_start"] = cell_colcell["row_end"] = cell_row + 1cell["col_end"] = cell_col + 1cell["x1"] = x_grids[cell_col]  # 绝对坐标cell["y1"] = y_grids[cell_row]cell["x2"] = x_grids[cell_col + 1]cell["y2"] = y_grids[cell_row + 1]cell["crnn"] = []  # 后续使用cell["text"] = ""  # 后续使用rst.append(cell)else:id_min = sorted(cell_id_sets[id])[0]id_max = sorted(cell_id_sets[id])[-1]cell = {}cell_row_min, cell_col_min = id_mincell_row_max, cell_col_max = id_maxcell["id"] = idcell["row_start"] = cell_row_min  # 结构坐标cell["col_start"] = cell_col_mincell["row_end"] = cell_row_max + 1cell["col_end"] = cell_col_max + 1cell["x1"] = x_grids[cell_col_min]  # 绝对坐标cell["y1"] = y_grids[cell_row_min]cell["x2"] = x_grids[cell_col_max + 1]cell["y2"] = y_grids[cell_row_max + 1]cell["crnn"] = []  # 后续使用cell["text"] = ""  # 后续使用rst.append(cell)return rst
# def str_cnt_ascii(str):
#     cnt = 0
#     for c in str:
#         if c <= "~":  # 是否准确?
#             cnt += 1
#     return cnt
#
#
# def clac_str_width(str):
#     """
#     计算字符最大宽度, 考虑换行和中英文的情况
#     记中文宽度为英文宽度的2倍
#     """
#     return max([2 * (len(t)) - str_cnt_ascii(t) for t in str.split('\n')])def debug_test_cell_excel():rst = simulate_data()#得到模拟数据print('rst:', rst)wb = Workbook()sheet1 = wb.add_sheet('Sheet 1', cell_overwrite_ok=True)style = xlwt.easyxf('align: wrap on, vert centre, horiz center')  # 设置行内换行, 水平竖直居中for b in rst:row_start = b['row_start']col_start = b['col_start']row_end = b['row_end']col_end = b['col_end']text = b['text']if (col_end - col_start == 1) and (row_end - row_start == 1):# # 自动调整列宽, 只对单个单元格(不计算合并单元格的内容情况)# cwidth = sheet1.col(col_start).width# column_txt_width = clac_str_width(text)# if (column_txt_width * 367) > cwidth:#     sheet1.col(col_start).width = (#             column_txt_width * 367)  # (Modify column width to match biggest data in that column)sheet1.write(row_start, col_start, text, style)else:sheet1.write_merge(row_start, row_end - 1,col_start, col_end - 1, text, style)wb.save("table_test.xls")if __name__ == '__main__':debug_test_cell_excel()

案例2:

import json
def table_save_excel(table_boxes, save_name):'''表格识别的内容存excel:param table_boxes::param save_name::return:'''# Writing to an excel# sheet using Pythondef str_cnt_ascii(str):cnt = 0for c in str:if c <= "~":  # 是否准确?cnt += 1return cntdef clac_str_width(str):"""计算字符最大宽度, 考虑换行和中英文的情况记中文宽度为英文宽度的2倍"""return max([2 * (len(t)) - str_cnt_ascii(t) for t in str.split('\n')])import xlwtfrom xlwt import Workbook# Workbook is createdwb = Workbook()# add_sheet is used to create sheet.sheet1 = wb.add_sheet('Sheet 1', cell_overwrite_ok=True)# todo 不添加覆盖操作有bug, 找出bug来源style = xlwt.easyxf('align: wrap on, vert centre, horiz center') # 设置行内换行, 水平竖直居中for b in table_boxes:print('b:', b)row_start = b['row_start']col_start = b['col_start']row_end = b['row_end']col_end = b['col_end']text = b['text']if (col_end - col_start == 1) and (row_end - row_start == 1):# 自动调整列宽, 只对单个单元格(不计算合并单元格的内容情况)cwidth = sheet1.col(col_start).widthcolumn_txt_width = clac_str_width(text)if (column_txt_width * 367) > cwidth:sheet1.col(col_start).width = (column_txt_width * 367)  # (Modify column width to match biggest data in that column)sheet1.write(row_start, col_start, text, style)else:sheet1.write_merge(row_start, row_end-1, col_start, col_end-1, text, style)wb.save(save_name)if __name__ == '__main__':# path = './json规范/json示意.txt'# with open(path, 'r', encoding='utf-8') as file:#     for i, read_info in enumerate(file.readlines()):#         print('read_info:', read_info)#其中row_start代表横线的开始,row_end代表横线的结束,col_start代表列线的开始,col_end代表列线的结束,'text'代表识别结果,x1,y1,x2,y2代表在图片中坐标,crnn准备放概率值table_boxes = [{'id': 0, 'row_start': 0, 'col_start': 0, 'row_end': 1, 'col_end': 6, 'x1': 121, 'y1': 472, 'x2': 833, 'y2': 499, 'crnn': [], 'text': '截止日期:2019年06月30日5单位:元'}, {'id': 1, 'row_start': 7, 'col_start': 0, 'row_end': 8, 'col_end': 6, 'x1': 121, 'y1': 711, 'x2': 833, 'y2': 740, 'crnn': [], 'text': '除以上所列结存或结欠贵公司之款额,本公司并无其他结存或结欠贵公司之款额。'}, {'id': 2, 'row_start': 2, 'col_start': 0, 'row_end': 6, 'col_end': 1, 'x1': 121, 'y1': 557, 'x2': 266, 'y2': 681, 'crnn': [], 'text': '应收贵公司金额\n应收账款\n其他应收款\n应收票据'}, {'id': 3, 'row_start': 2, 'col_start': 3, 'row_end': 6, 'col_end': 4, 'x1': 487, 'y1': 557, 'x2': 622, 'y2': 681, 'crnn': [], 'text': '应付贵公司金额\n应付账款\n其他应付款\n应付票据'}, {'id': 4, 'row_start': 1, 'col_start': 0, 'row_end': 2, 'col_end': 1, 'x1': 121, 'y1': 499, 'x2': 266, 'y2': 557, 'crnn': [], 'text': '项目'}, {'id': 5, 'row_start': 6, 'col_start': 0, 'row_end': 7, 'col_end': 1, 'x1': 121, 'y1': 681, 'x2': 266, 'y2': 711, 'crnn': [], 'text': '预付贵公司金额'}, {'id': 6, 'row_start': 1, 'col_start': 1, 'row_end': 2, 'col_end': 2, 'x1': 266, 'y1': 499, 'x2': 391, 'y2': 557, 'crnn': [], 'text': '本公司账面金\n额'}, {'id': 7, 'row_start': 2, 'col_start': 1, 'row_end': 3, 'col_end': 2, 'x1': 266, 'y1': 557, 'x2': 391, 'y2': 588, 'crnn': [], 'text': '\n'}, {'id': 8, 'row_start': 3, 'col_start': 1, 'row_end': 4, 'col_end': 2, 'x1': 266, 'y1': 588, 'x2': 391, 'y2': 619, 'crnn': [], 'text': '\n'}, {'id': 9, 'row_start': 4, 'col_start': 1, 'row_end': 5, 'col_end': 2, 'x1': 266, 'y1': 619, 'x2': 391, 'y2': 649, 'crnn': [], 'text': '\n'}, {'id': 10, 'row_start': 5, 'col_start': 1, 'row_end': 6, 'col_end': 2, 'x1': 266, 'y1': 649, 'x2': 391, 'y2': 681, 'crnn': [], 'text': '\n'}, {'id': 11, 'row_start': 6, 'col_start': 1, 'row_end': 7, 'col_end': 2, 'x1': 266, 'y1': 681, 'x2': 391, 'y2': 711, 'crnn': [], 'text': ''}, {'id': 12, 'row_start': 1, 'col_start': 2, 'row_end': 2, 'col_end': 3, 'x1': 391, 'y1': 499, 'x2': 487, 'y2': 557, 'crnn': [], 'text': '如金额不符,请\n列明贵公司账面\n记承的金额(注)'}, {'id': 13, 'row_start': 2, 'col_start': 2, 'row_end': 3, 'col_end': 3, 'x1': 391, 'y1': 557, 'x2': 487, 'y2': 588, 'crnn': [], 'text': ''}, {'id': 14, 'row_start': 3, 'col_start': 2, 'row_end': 4, 'col_end': 3, 'x1': 391, 'y1': 588, 'x2': 487, 'y2': 619, 'crnn': [], 'text': '\n'}, {'id': 15, 'row_start': 4, 'col_start': 2, 'row_end': 5, 'col_end': 3, 'x1': 391, 'y1': 619, 'x2': 487, 'y2': 649, 'crnn': [], 'text': ''}, {'id': 16, 'row_start': 5, 'col_start': 2, 'row_end': 6, 'col_end': 3, 'x1': 391, 'y1': 649, 'x2': 487, 'y2': 681, 'crnn': [], 'text': '\n'}, {'id': 17, 'row_start': 6, 'col_start': 2, 'row_end': 7, 'col_end': 3, 'x1': 391, 'y1': 681, 'x2': 487, 'y2': 711, 'crnn': [], 'text': '\n'}, {'id': 18, 'row_start': 1, 'col_start': 3, 'row_end': 2, 'col_end': 4, 'x1': 487, 'y1': 499, 'x2': 622, 'y2': 557, 'crnn': [], 'text': '项目'}, {'id': 19, 'row_start': 6, 'col_start': 3, 'row_end': 7, 'col_end': 4, 'x1': 487, 'y1': 681, 'x2': 622, 'y2': 711, 'crnn': [], 'text': '预收贵公司金额'}, {'id': 20, 'row_start': 1, 'col_start': 4, 'row_end': 2, 'col_end': 5, 'x1': 622, 'y1': 499, 'x2': 739, 'y2': 557, 'crnn': [], 'text': '本公司账面金\n额'}, {'id': 21, 'row_start': 2, 'col_start': 4, 'row_end': 3, 'col_end': 5, 'x1': 622, 'y1': 557, 'x2': 739, 'y2': 588, 'crnn': [], 'text': ''}, {'id': 22, 'row_start': 3, 'col_start': 4, 'row_end': 4, 'col_end': 5, 'x1': 622, 'y1': 588, 'x2': 739, 'y2': 619, 'crnn': [], 'text': '1,254,555.54'}, {'id': 23, 'row_start': 4, 'col_start': 4, 'row_end': 5, 'col_end': 5, 'x1': 622, 'y1': 619, 'x2': 739, 'y2': 649, 'crnn': [], 'text': '2,000.00'}, {'id': 24, 'row_start': 5, 'col_start': 4, 'row_end': 6, 'col_end': 5, 'x1': 622, 'y1': 649, 'x2': 739, 'y2': 681, 'crnn': [], 'text': ''}, {'id': 25, 'row_start': 6, 'col_start': 4, 'row_end': 7, 'col_end': 5, 'x1': 622, 'y1': 681, 'x2': 739, 'y2': 711, 'crnn': [], 'text': '\n'}, {'id': 26, 'row_start': 1, 'col_start': 5, 'row_end': 2, 'col_end': 6, 'x1': 739, 'y1': 499, 'x2': 833, 'y2': 557, 'crnn': [], 'text': '列明贵公司账\n面记录的金额\n(注)'}, {'id': 27, 'row_start': 2, 'col_start': 5, 'row_end': 3, 'col_end': 6, 'x1': 739, 'y1': 557, 'x2': 833, 'y2': 588, 'crnn': [], 'text': ''}, {'id': 28, 'row_start': 3, 'col_start': 5, 'row_end': 4, 'col_end': 6, 'x1': 739, 'y1': 588, 'x2': 833, 'y2': 619, 'crnn': [], 'text': ''}, {'id': 29, 'row_start': 4, 'col_start': 5, 'row_end': 5, 'col_end': 6, 'x1': 739, 'y1': 619, 'x2': 833, 'y2': 649, 'crnn': [], 'text': ''}, {'id': 30, 'row_start': 5, 'col_start': 5, 'row_end': 6, 'col_end': 6, 'x1': 739, 'y1': 649, 'x2': 833, 'y2': 681, 'crnn': [], 'text': '\n'}, {'id': 31, 'row_start': 6, 'col_start': 5, 'row_end': 7, 'col_end': 6, 'x1': 739, 'y1': 681, 'x2': 833, 'y2': 711, 'crnn': [], 'text': ''}]print('table_boxes:', table_boxes)save_name = './test.xls'print('table_boxes[0]', table_boxes[0])table_save_excel(table_boxes, save_name)

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

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

相关文章

为了边缘计算,亚马逊、谷歌、微软已正面交锋!

来源&#xff1a;全球物联网观察摘要&#xff1a;so&#xff0c;你真的了解边缘计算吗&#xff1f;边缘计算的前世今生云计算自2005年提出之后&#xff0c;就开始逐步地改变我们的生活、学习、工作的方式。云计算使得公司能够在自己的物理硬件之外&#xff0c;通过远程服务器网…

每日一小练——二项式系数加法解

上得厅堂&#xff0c;下得厨房&#xff0c;写得代码&#xff0c;翻得围墙&#xff0c;欢迎来到睿不可挡的每日一小练&#xff01; 题目&#xff1a;二项式系数加法解 内容&#xff1a;请编写一个程序&#xff0c;仅仅用加法&#xff0c;求出n中取r个组合系数C(n,r)&#xff0c;…

华为、苹果、高通,谁在领跑?全面解读清华AI芯片报告

来源&#xff1a;智东西摘要&#xff1a;本文全面讲解人工智能芯片&#xff0c;系统梳理人工智能芯片的发展现状及趋势。2010 年以来&#xff0c;由于大数据产业的发展&#xff0c;数据量呈现爆炸性增长态势&#xff0c;而传统的计算架构又无法支撑深度学习的大规模并行计算需求…

SSD300网络结构(pytorch)+多尺度训练与测试

一.SSD300 1.如图是预测框的相应feature map 这里smin是0.2&#xff0c;表示最底层的scale是0.2&#xff1b;smax是0.9&#xff0c;表示最高层的scale是0.9,m代表产生尺度预测的feature map个数。 其中anchor的长宽关系&#xff0c;s就是上图中的scale,a就是上图中的anchor …

01-08-02【Nhibernate (版本3.3.1.4000) 出入江湖】二级缓存:NHibernate自带的HashtableProvider...

第一步骤&#xff1a;hibernate.cfg.xml文件补上如下配置&#xff1a; <?xml version"1.0" encoding"utf-8"?> <!-- This template was written to work with NHibernate.Test. Copy the template to your NHibernate.Test project folder and…

2018, 自动驾驶异常艰难的一年

编译&#xff1a;张玺 &#xff0c;编辑&#xff1a;宇多田摘要&#xff1a;虽然文章几乎聚焦于美国硅谷的技术公司&#xff0c;但这并不意味着作者提出的种种问题不存在于中国的技术公司身上。有意思的是&#xff0c;作者批评了各大公司此前疯狂立 flag&#xff0c;却最后纷纷…

目标检测矩形框与polygon数据增加--裁剪,拓展,旋转

1.裁剪 import torch from torchvision import transforms import cv2 import numpy as np import types from numpy import random class RandomSampleCrop(object):"""CropArguments:img (Image): the image being input during trainingboxes (Tensor): th…

医生们说,AI不会取代我们!

来源&#xff1a;IEEE电气电子工程师学会每次人工智能在医疗任务中与医生进行竞争&#xff08;对此我们已经报道过很多次&#xff09;时&#xff0c;一个问题不可避免地浮出水面&#xff1a;人工智能会取代医生吗&#xff1f;如果你与AI 专家或硅谷投资者交谈&#xff0c;答案往…

ubuntu安装python3.5+pycharm+anaconda+opencv+docker+nvidia-docker+tensorflow+pytorch+Cmake3.8

一&#xff0c;切换python版本为3.5 装好ubuntu&#xff0c;python版本是2.7的 我自己安装并更改打开为python3.5 sudo apt-get install python3.5 设置优先级和默认环境&#xff1a; sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 su…

学界 | 量化深度强化学习算法的泛化能力

来源&#xff1a;AI 科技评论OpenAI 近期发布了一个新的训练环境 CoinRun&#xff0c;它提供了一个度量智能体将其学习经验活学活用到新情况的能力指标&#xff0c;而且还可以解决一项长期存在于强化学习中的疑难问题——即使是广受赞誉的强化算法在训练过程中也总是没有运用监…

《科学》评出2018年度十大科学突破事件

来源&#xff1a;科学大院《科学》杂志每年会评出在即将过去的一年里最为重要的十大科学突破&#xff08;Science Breakthrough&#xff09;。今年&#xff0c;夺得年度突破桂冠的是“单细胞水平细胞谱系追踪技术”&#xff0c;帮助破获多起悬案的法医系谱技术、#MeToo 运动等也…

递归理解以及时间复杂度计算

一.复杂度分析&#xff1a; 可以理解为递归的深度就是空间复杂度&#xff0c;时间复杂度就是O(T*depth),其中&#xff34;是每个递归函数的时间复杂度&#xff0c;depth是递归深度&#xff0e; #空间复杂度O(1) def sum1_(n):res 0for i in range(n1):resireturn res#递归 空…

性价比高出英特尔45%,亚马逊的云服务器芯片如何做到?| 解读

来源&#xff1a;TheNextPlatform编译&#xff1a;机器之能 张玺摘要&#xff1a;到目前为止&#xff0c;亚马逊和其他大型云运营商几乎全部使用英特尔的 Xeon 芯片。虽然在服务器芯片市场&#xff0c;英特尔市场占有率非常高&#xff0c;但亚马逊正使用折扣策略来赢得客户。亚…

GIOU loss+DIOU loss+CIOU loss

一.IOU 1.GIOU解决没有交集的框,IOU为0,其损失函数导数为0,无法优化的问题。 图1 GIOU,IOU,l2范数差异 a)可看出 l2值一样,IOU值是不一样的,说明L1,L2这些Loss用于回归任务时&#xff0c;不能等价于最后用于评测检测的IoU. b)可看出当框有包含关系,GIOU就退化为IOU 其是找…

《科学》十大年度科学突破反映的新动向

来源&#xff1a;新华网摘要&#xff1a;从测定分子结构到宇宙探索&#xff0c;从发现远古动物到揭示细胞的秘密&#xff0c;美国权威学术刊物《科学》杂志评选的2018年十大科学突破&#xff0c;在时间和空间尺度上拓宽着人类认知的边界&#xff0c;也反映了近年来科学发展的三…

ctpn论文阅读与代码

代码地址: https://github.com/zonghaofan/ctpn_torch 1.通用的目标检测是封闭的,而文字是封闭且连续 2. 构造一系列宽度相等的小文本,回归中心y坐标和高度 3. 对于边界回归x坐标,在进一次修正 4.整个模型就是backbone提取特征,将每个像素点的相邻3*3像素拉成行向量,利用空间…

yum配置与使用

yum配置与使用(很详细) yum的配置一般有两种方式&#xff0c;一种是直接配置/etc目录下的yum.conf文件&#xff0c;另外一种是在/etc/yum.repos.d目录下增加.repo文件。一、yum的配置文件$ cat /etc/yum.conf [main]cachedir/var/cache/yum #yum下载的RPM包的缓存目录k…

新技术不断涌现,下一代云计算的突破口在哪里?

来源&#xff1a;日知录技术社区这是一个IT技术飞速发展的时代&#xff0c;在硬件基础设施的不断升级以及虚拟化网络等技术的日益成熟下&#xff0c;云厂商也正面临着各种新技术带来的巨大挑战。从数据中心的基础建设到云平台的系统构建再到产品底层的技术改革&#xff0c;该如…

生成高斯热力图(craft中有使用)+2d heatmap+3d heatmap

一.生成高斯热力图 from math import exp import numpy as np import cv2 import osclass GaussianTransformer(object):def __init__(self, imgSize512, region_threshold0.4,affinity_threshold0.2):distanceRatio 3.34scaledGaussian lambda x: exp(-(1 / 2) * (x ** 2))…

POP动画[1]

POP动画[1] pop动画是facebook扩展CoreAnimation的,使用及其方便:) 1:Spring系列的弹簧效果(两个动画kPOPLayerBounds与kPOPLayerCornerRadius同时运行) #import "RootViewController.h" #import "YXEasing.h" #import "POP.h" #import "YX…