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

天猫店的网站怎么做的sem是什么显微镜

天猫店的网站怎么做的,sem是什么显微镜,一般的信息网站用什么做,jsp网站制作数据集批量更新分类OR删除分类行数据 import osdef remove_class_from_file(file_path, class_to_remove):"""从YOLO格式的标注文件中删除指定类别的行记录,并去除空行。:param file_path: YOLO标注文件路径:param class_to_remove: 需要删除的类别…

数据集批量更新分类OR删除分类行数据

import osdef remove_class_from_file(file_path, class_to_remove):"""从YOLO格式的标注文件中删除指定类别的行记录,并去除空行。:param file_path: YOLO标注文件路径:param class_to_remove: 需要删除的类别ID:return: 删除的行数"""deleted_lines = 0# 读取原始数据with open(file_path, 'r') as file:lines = file.readlines()# 过滤掉指定类别的行filtered_lines = [line for line in lines if not line.startswith(f"{class_to_remove} ")]# 去除空行cleaned_lines = [line for line in filtered_lines if line.strip()]# 计算删除的行数deleted_lines = len(lines) - len(cleaned_lines)# 将清理后的数据写回文件with open(file_path, 'w') as file:file.writelines(cleaned_lines)return deleted_linesdef update_class_in_file(file_path, old_class, new_class):"""将YOLO格式的标注文件中指定类别的数字更新为新的类别ID。:param file_path: YOLO标注文件路径:param old_class: 需要更新的旧类别ID:param new_class: 更新后的新类别ID:return: 更新的行数"""updated_lines = 0# 读取原始数据with open(file_path, 'r') as file:lines = file.readlines()# 更新类别IDupdated_lines = 0new_lines = []for line in lines:if line.startswith(f"{old_class} "):new_lines.append(line.replace(f"{old_class} ", f"{new_class} ", 1))updated_lines += 1else:new_lines.append(line)# 将更新后的数据写回文件with open(file_path, 'w') as file:file.writelines(new_lines)return updated_linesdef process_directory(directory_path, class_to_remove=None, old_class=None, new_class=None):"""处理指定目录下的所有YOLO标注文件,可以选择删除指定类别的记录或更新分类数字。:param directory_path: 目录路径:param class_to_remove: 需要删除的类别ID(如果需要删除指定类别的记录):param old_class: 需要更新的旧类别ID(如果需要更新分类数字):param new_class: 更新后的新类别ID(如果需要更新分类数字)"""total_deleted_lines = 0total_updated_lines = 0# 遍历目录中的文件for filename in os.listdir(directory_path):if filename.endswith('.txt'):  # 假设标注文件都是以 .txt 结尾的file_path = os.path.join(directory_path, filename)if class_to_remove is not None:deleted_lines = remove_class_from_file(file_path, class_to_remove)print(f"已从文件 {filename} 中删除类别 {class_to_remove} 的记录,共删除 {deleted_lines} 行。")total_deleted_lines += deleted_linesif old_class is not None and new_class is not None:updated_lines = update_class_in_file(file_path, old_class, new_class)print(f"已从文件 {filename} 中将类别 {old_class} 更新为 {new_class},共更新 {updated_lines} 行。")total_updated_lines += updated_linesif class_to_remove is not None:print(f"总共删除了 {total_deleted_lines} 行记录。")if old_class is not None and new_class is not None:print(f"总共更新了 {total_updated_lines} 行记录。")# 使用示例
directory_path = 'C:\\Users\\合格的牛马\\Desktop\\datasets\\test-delete\\labels'  # 替换为你的目录路径# 删除指定类别的记录
class_to_remove = 5  # 替换为你要删除的类别ID
process_directory(directory_path, class_to_remove=class_to_remove)# 更新指定类别的分类数字
old_class = 1  # 替换为旧类别ID
new_class = 100  # 替换为新类别ID
process_directory(directory_path, old_class=old_class, new_class=new_class)
http://www.ds6.com.cn/news/68121.html

相关文章:

  • 医院网站建设方案计划书google play应用商店
  • 电子商务网站的建设报告市场营销推广策划方案
  • 杭州高端网站建设搜索引擎营销的案例
  • wordpress注册登录问题网站seo快速排名优化的软件
  • 怎么做网站首页关键词深圳百度推广竞价托管
  • 网站后台的关键词福州关键词排名软件
  • 网站建设与设计实验报告市场调研报告范文模板
  • 网站网页能自己做吗网站排名seo教程
  • app开发定制外包22宁阳网站seo推广
  • 网站读取错误时怎样做网络营销策略优化
  • 哪个网站教做饭做的好交换友情链接的意义是什么
  • 网站申请免费培训心得模板
  • 微信网站建设热线免费公司网站建站
  • 做网站的成本在哪广州营销课程培训班
  • 国内ui做的好的网站有哪些如何做好网络销售技巧
  • 有没有教做黄色网站厦门seo推广优化
  • 亚运会110周年庆典在杭州举行长沙网站优化方法
  • 苏州企业网站建设专家站点查询
  • 网站代付系统怎么做放心网站推广优化咨询
  • 北京免费网站建设模板大数据培训班出来能就业吗
  • 水友做的yyf网站全网热度指数
  • 旧域名新网站品牌推广的方式
  • 做前端的女生压力大吗seo黑帽培训骗局
  • 网站h1标签的应用好的竞价托管公司
  • 免费建网站系统西安百度网站排名优化
  • 郑州网站建设包括哪些品牌推广是做什么的
  • 河北网站建设报价韶山seo快速排名
  • 河北省住房与建设厅网站首页自助建站模板
  • 市桥做网站的公司做网络推广
  • 做网站需要去工商备案吗关键词快速排名平台