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

郑州网站分析米泉seo快速排名

郑州网站分析,米泉seo快速排名,哪些网站是动态,石家庄模板建站平台将分割的mask转换为分割标签通常涉及将每个像素的类别标识#xff08;在mask中以不同的灰度值或颜色表示#xff09;转换为整数标签。这些标签通常用于机器学习或深度学习模型的训练、验证和测试阶段。 使用方式#xff0c;控制台或者命令行使用以下命令#xff1a; pyth…将分割的mask转换为分割标签通常涉及将每个像素的类别标识在mask中以不同的灰度值或颜色表示转换为整数标签。这些标签通常用于机器学习或深度学习模型的训练、验证和测试阶段。 使用方式控制台或者命令行使用以下命令 python polygon_mask_conversion.py --img_path xxx_folder --mask_path xxx_folder --mode mask2poly 转换代码来自X_anyLabeling的tool文件夹下的转换文件。 import argparse import json import os import time import cv2from PIL import Image from tqdm import tqdm from datetime import dateimport numpy as np import matplotlib as pltimport syssys.path.append(./) from anylabeling.app_info import __version__# Usage # # # # -------------------------------------------------------------------- mask2poly ----------------------------------------------------------------------# # python tools/polygon_mask_conversion.py --img_path xxx_folder --mask_path xxx_folder --mode mask2poly # # # # -------------------------------------------------------------------- poly2mask ----------------------------------------------------------------------# # [option1] python tools/polygon_mask_conversion.py --img_path xxx_folder --mask_path xxx_folder --mode poly2mask # # [option2] python tools/polygon_mask_conversion.py --img_path xxx_folder --mask_path xxx_folder --json_path xxx_folder --mode poly2mask # # # # Usage #VERSION __version__ IMG_FORMATS [.bmp,.dng,.jpeg,.jpg,.mpo,.png,.tif,.tiff,.webp,.pfm, ]class PolygonMaskConversion:def __init__(self, epsilon_factor0.001):self.epsilon_factor epsilon_factordef reset(self):self.custom_data dict(versionVERSION,flags{},shapes[],imagePath,imageDataNone,imageHeight-1,imageWidth-1,)def get_image_size(self, image_file):with Image.open(image_file) as img:width, height img.sizereturn width, heightdef mask_to_polygon(self, img_file, mask_file, json_file):self.reset()binary_mask cv2.imread(mask_file, cv2.IMREAD_GRAYSCALE)contours, _ cv2.findContours(binary_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)for contour in contours:epsilon self.epsilon_factor * cv2.arcLength(contour, True)approx cv2.approxPolyDP(contour, epsilon, True)if len(approx) 5:continueshape {label: object,text: ,points: [],group_id: None,shape_type: polygon,flags: {},}for point in approx:x, y point[0].tolist()shape[points].append([x, y])self.custom_data[shapes].append(shape)image_width, image_height self.get_image_size(img_file)self.custom_data[imagePath] os.path.basename(img_file)self.custom_data[imageHeight] image_heightself.custom_data[imageWidth] image_widthwith open(json_file, w, encodingutf-8) as f:json.dump(self.custom_data, f, indent2, ensure_asciiFalse)def polygon_to_mask(self, img_file, mask_file, json_file):with open(json_file, r) as f:data json.load(f)polygons []for shape in data[shapes]:points shape[points]polygon []for point in points:x, y pointpolygon.append((x, y))polygons.append(polygon)image_width, image_height self.get_image_size(img_file)image_shape (image_height, image_width)binary_mask np.zeros(image_shape, dtypenp.uint8)for polygon_points in polygons:np_polygon np.array(polygon_points, np.int32)np_polygon np_polygon.reshape((-1, 1, 2))cv2.fillPoly(binary_mask, [np_polygon], color255)cv2.imwrite(mask_file, binary_mask)def main():parser argparse.ArgumentParser(descriptionPolygon Mask Conversion)parser.add_argument(--img_path, helpPath to image directory)parser.add_argument(--mask_path, helpPath to mask directory)parser.add_argument(--json_path, default, helpPath to json directory)parser.add_argument(--epsilon_factor,default0.001,typefloat,helpControl the level of simplification when converting a polygon contour to a simplified version,)parser.add_argument(--mode,choices[mask2poly, poly2mask],requiredTrue,helpChoose the conversion mode what you need,)args parser.parse_args()print(fStarting conversion to {args.mode}...)start_time time.time()converter PolygonMaskConversion(args.epsilon_factor)if args.mode mask2poly:file_list os.listdir(args.mask_path)for file_name in tqdm(file_list, descConverting files, unitfile, colourblue):img_file os.path.join(args.img_path, file_name)mask_file os.path.join(args.mask_path, file_name)json_file os.path.join(args.img_path, os.path.splitext(file_name)[0] .json)converter.mask_to_polygon(img_file, mask_file, json_file)elif args.mode poly2mask:# Only binary mask transformations are supported.os.makedirs(args.mask_path, exist_okTrue)file_list os.listdir(args.img_path)for file_name in tqdm(file_list, descConverting files, unitfile, colourblue):base_name, suffix os.path.splitext(file_name)if suffix.lower() not in IMG_FORMATS:continueimg_file os.path.join(args.img_path, file_name)if not args.json_path:json_file os.path.join(args.img_path, base_name .json)else:json_file os.path.join(args.json_path, base_name .json)mask_file os.path.join(args.mask_path, base_name .png)converter.polygon_to_mask(img_file, mask_file, json_file)end_time time.time()print(fConversion completed successfully!)print(fConversion time: {end_time - start_time:.2f} seconds)if __name__ __main__:main()
http://www.eeditor.cn/news/119279/

相关文章:

  • 商城网站 不易优化mvc5网站开发实战详解
  • 做的网站百度搜不到品牌网站建设网站
  • 做爰片的网站手机网站 asp
  • 深圳外贸网站做任务免费领取东西的网站
  • 营销型企业网站建设的预算建一个展示网站下班多少钱
  • 国内网站开发不用wordpress国外做外贸的网站
  • 镇江网站推广排名网站建设实例大制作
  • 遵义一般做一个网站需要多少钱站外推广策划书
  • 建设局网站外贸网站建设有哪些要求
  • 网站如何导入织梦cms中国制造网外贸平台
  • 如何访问国外网站手机设计logo软件
  • 石家庄响应式模板建站wordpress默认参数
  • 网站免费制作平台这样做自己公司的网站
  • 离型剂技术支持东莞网站建设云南建投第七建设有限公司网站
  • jsp ajax网站开发典型实例 pdf软文发稿平台有哪些
  • 石家庄市高新区建设局网站交换友情链接的途径有哪些
  • 安徽合肥网站制作wordpress可视化建站
  • 家装e站怎么学习做网站
  • 网站如何做点击链接佛山响应式网站
  • 网站 架构 设计海报设计在线生成免费
  • 建设银行官方网站面试详细信息济南做网站的公司哪家好
  • 国外设计网站欣赏上海优化seo排名
  • 怎么查网站的浏览量成都市城乡建设局网站
  • 做公益网站需要什么资质站长工具seo综合查询5g
  • 网站制作规划设计内容浙江省台州市做网站多少钱
  • 上海建设工程咨询网招聘seo网络排名优化
  • 网站建设公司使用图片侵权使用者有无责任安徽省住房建设工程信息网站
  • 学校网站建设先进个人荣誉淄博做网站多少钱
  • 桂林学校网站制作目录 首页 wordpress
  • 做电商看的网站有哪些内容大庆建设公司网站