当前位置: 首页 > news >正文

网站构建是什么电子商务和市场营销的区别

网站构建是什么,电子商务和市场营销的区别,合肥万户网络科技有限公司,小程序商家入驻平台前言 都知道标注很麻烦、很累#xff0c;不然先训练一批#xff0c;然后推理得到它的掩码图#xff0c;先生成自动标注#xff0c;再人工手动修改也许会快很多 半自动标注代码 这是我自己写的#xff0c;是labelme的格式#xff0c;大家想要修改成自己的json格式可以修…前言 都知道标注很麻烦、很累不然先训练一批然后推理得到它的掩码图先生成自动标注再人工手动修改也许会快很多 半自动标注代码 这是我自己写的是labelme的格式大家想要修改成自己的json格式可以修改json_dict_init与dict_init函数 默认大家已经得到自己图片经过模型推理之后的掩码图了掩码图上面生成的像素应该是0,1,2,3. 分别对应自己训练的时候的标签 import cv2 import sys import base64 import cv2 import json import time import os from tqdm import tqdm from PIL import Image import numpy as npdef dict_init(label_name):temp_dict {label: label_name,line_color: None,fill_color: None,points:[],shape_type: polygon,flags: {}}return temp_dictdef json_dict_init(num,height,width,img):temp_dict {version: 3.16.2,flags: {},shapes: [],lineColor: [0,255,0,128],fillColor: [255,0,0,128],imagePath: ..\\img\\{}.jpg.format(num),#原图像数据通过b64编码生成的字符串数据可以再次解码成图片imageData:img,imageHeight: height,imageWidth: width}return temp_dictdef image_to_base64(image_path):# 读取二进制图片获得原始字节码with open(image_path, rb) as jpg_file:byte_content jpg_file.read()# 把原始字节码编码成base64字节码base64_bytes base64.b64encode(byte_content)# 把base64字节码解码成utf-8格式的字符串base64_string base64_bytes.decode(utf-8)return base64_string# 定义一个函数用于判断两个点是否相邻 def is_adjacent(pt1, pt2):x1, y1 pt1x2, y2 pt2return abs(x1 - x2) 8 and abs(y1 - y2) 8def main():img_path D:/data_val/new/temp/imglabel_path D:/data_val/new/temp/labeljson_save_path D:/data_val/new/temp/jsonos.makedirs(json_save_path,exist_okTrue)# 放入你的标签名 例如 你的掩码图 像素是1 1对应的就是phone 像素是2 2就是linelabel_name_list [phone,line]img_list os.listdir(img_path)pbar tqdm(totallen(img_list))for filename in img_list:name filename.split(.)[0]# print(**10)# print(f{filename})#label图label Image.open(f{label_path}/{name}.png)label np.array(label)#输出自己的label有多少种像素# unique_values np.unique(label)# print()# print(unique_values)# print()height label.shape[0]width label.shape[1]base64_string image_to_base64(f{img_path}/{filename})json_dict json_dict_init(name,height,width,base64_string)contours, hierarchy cv2.findContours(label, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)background_flag Falseif (len(contours) 0):print(如果未识别到 则变成背景)shapes_dict dict_init(_background_)left_top, left_botton [10, 10], [10, height - 10]right_botton, right_top [width - 10, height - 10], [width - 10, 10]shapes_dict[points] [left_top, left_botton, right_botton, right_top]json_dict[shapes].append(shapes_dict)else:for i,clasee_name in enumerate(label_name_list):temp label.copy()temp[temp!(i1)] 0contours, hierarchy cv2.findContours(temp, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)if (len(contours) 0):continueelse:count 0for contour in contours:shapes_dict dict_init(clasee_name)count count 1#10 20#语义分割approxCourve cv2.approxPolyDP(contour, 3, True)for Courve in approxCourve:point Courve[0]x, y pointx int(x)y int(y)temp_list []temp_list.append(x)temp_list.append(y)shapes_dict[points].append(temp_list)#目标检测 这里只写到生成检测框的四个点 根据自己需求填进去# rect cv2.minAreaRect(contour)# box cv2.boxPoints(rect)# # print(box)# # 轮廓必须是整数, 不能是小数, 所以转化为整数# box np.round(box).astype(int64)# left_point_x np.min(box[:, 0])# right_point_x np.max(box[:, 0])# top_point_y np.min(box[:, 1])# bottom_point_y np.max(box[:, 1])json_dict[shapes].append(shapes_dict)with open(f{json_save_path}/{name}.json, w, encodingutf-8) as f:f.write(json.dumps(json_dict, ensure_asciiFalse))pbar.update(1)if __name__ __main__:main()
http://www.zqtcl.cn/news/855655/

相关文章:

  • 网站建设要准备什么资料网站建设 锐颖科技
  • 如何建设网站山东济南兴田德润官网电子商城官网
  • 网站如何做支付宝接口免费ppt自动生成器
  • 泰安市建设职工培训中心网站官网seo经理招聘
  • 湛江做网站seo网站建设 0551
  • 建站公司 深圳苏州建站公司
  • 网站怎么做引流呢济南网站微信
  • 一个域名可以做几个网站吗wordpress左右翻转页面
  • 天津人工智能建站系统软件wordpress主题没有小工具
  • 网站的备案流程图视频制作素材
  • 劳务公司网站建设方案建设促销网站前的市场分析
  • 网络营销优化培训网站seo置顶 乐云践新专家
  • 小说网站搭建教程wordpress后台图片
  • 付网站开发费计入什么科目网站开发的历史
  • 站长素材ppt模板免费下载网站开发视频教程迅雷下载
  • 建设一个网站怎么赚钱南京江北新区房价走势最新消息
  • 一个网站怎么做软件下载互联网投放渠道有哪些
  • 手机网站建设进度环境设计排版素材网站
  • 网站开发众筹地推网推平台
  • 长沙互联网网站建设wordpress标签id在哪里修改
  • 企业网站的建设 摘要大连网站设计策划
  • 做房地产一级市场的看什么网站网络营销外包推广方式
  • 网站建设基本流程包括哪几个步骤网站建设策划书网站发布与推广
  • 徐州整站优化手机网页端
  • 深圳中瑞建设集团官方网站宁波seo快速优化教程
  • 福田网站制作哪家好昆山企业网站建设公司
  • wordpress快六安网站自然排名优化价格
  • 网站的线下推广怎么做的系统官网网站模板下载安装
  • 北京网站优化推广公司企业网站建设费怎么核算
  • 网站建设vps个人如何做网站推广