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

天猫店的网站怎么做的深圳网络seo推广

天猫店的网站怎么做的,深圳网络seo推广,系统软件开发培训机构,市政府网站集约化建设难点数据集批量更新分类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.tj-hxxt.cn/news/84734.html

相关文章:

  • 张家港早晨网站制作百度店铺怎么入驻
  • 湖北网站建设 鄂 icp运营培训班有用吗
  • 做海报挣钱的网站全球搜索引擎网站
  • 油气集输毕业设计代做网站阿里巴巴seo排名优化
  • 郑州微网站制作营销型网站制作
  • 长春做网站哪里好专门发广告的app
  • 襄阳手机网站建设网络营销的定义
  • php宠物用品公司网站源码360点睛实效平台推广
  • 第三方网站下载素材是怎么做百度seo建议
  • 国内哪个推广网站做的好宁德市蕉城区
  • 风科网免费网站友情链接举例
  • 如何自制一个网站搜索引擎营销seo
  • 北京漫步云端网站建设外贸独立站推广
  • 各大高校的校园网站建设软文是什么样子的
  • 网站备案掉了怎么办如何做推广推广技巧
  • 网站制作建站程序西安seo包年服务
  • 杭州软件定制开发网站做优化一开始怎么做
  • 社区居委会网站建设公司官网模板
  • 做外贸应该去什么网站整合营销策划方案模板
  • 美国人做的汉字网站网上推销产品去什么平台
  • 柳州网站建设源码网络推广外包公司哪家好
  • 沈阳手机网站建设专业seo站长工具
  • 淘宝做网站骗局活动策划方案详细模板
  • 智慧团建网站登陆平台镇江网站关键字优化
  • 网站建设如何快速增加用户哪个平台推广效果好
  • 哪个网站有上门做指甲php开源建站系统
  • 深圳市建网站公司外贸推广哪个公司好
  • 律师网站建设公司打开网址资料网站
  • 橙子建站的验证码安全吗女生读网络营销与电商直播
  • 武汉建网站的网站淘宝网店代运营正规公司