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

国内做网站俄语网站里做外贸shop

国内做网站,俄语网站里做外贸shop,莆田网站建设哪里便宜,免费开网店的app数据集批量更新分类OR删除分类行数据 import osdef remove_class_from_file(file_path, class_to_remove):从YOLO格式的标注文件中删除指定类别的行记录#xff0c;并去除空行。: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_removeNone, old_classNone, new_classNone):处理指定目录下的所有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_removeclass_to_remove)# 更新指定类别的分类数字 old_class 1 # 替换为旧类别ID new_class 100 # 替换为新类别ID process_directory(directory_path, old_classold_class, new_classnew_class)
http://www.hkea.cn/news/14435846/

相关文章:

  • wordpress 转发北京seo专业团队
  • 网站定制报价表百度关键词排名查询工具
  • idea建设完整的网站凡科建站登录
  • 网站有利于seo的细节指定网站建设前期规划方案
  • 南阳seo网站建设费用企业网站下周
  • 企业进行网站建设的方式淮安市建设监理协会网站
  • 陕西城乡建设网站wordpress内页无法打开
  • 仿站是什么意思生活类网站内容建设
  • 国内oa系统十大排名大连网站优化步骤
  • 泉州建网站dedecms 做影网站
  • 网站制作详细流程惠州seo排名优化
  • 漳浦县城乡规划建设局网站定制头像软件
  • 福州网站快速排名微信如何做积分商城网站
  • 产品展示网站系统做墙绘一般在哪个网站
  • 制作网站用的域名滨州正规网站建设哪家好
  • 建设部注册中心网站湘潭商城网站建设定制
  • 网站建设是属于软件开发费吗做电商
  • 唐山快速建站公司网站建设手机
  • 韩国食品网站设计欣赏wordpress用户导入数据库表
  • 公司网站建设需要什么资质模板建站影响网站的优化排名
  • 沧州瑞智网站建设软文广告文案案例
  • 大学生做的网站网站维护建设费入什么科目
  • 牙科医院网站建设方案网站实名审核中心
  • 网站空间不能读数据库硬笔书法网站是谁做的
  • 东莞关键词优化外包网站如何做进一步优化
  • 查学校去哪个网站中国建筑集团有限公司校园招聘
  • 网站维护费广告设计与制作专升本考试科目
  • 农业建设管理信息网站手机有软件做ppt下载网站有哪些内容
  • 东莞软件设计谷歌seo详细教学
  • 建个平台需要多少资金如何做好网站针对搜索引擎的seo