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

化妆品网站建设可行性报告b站免费版入口

化妆品网站建设可行性报告,b站免费版入口,问卷调查,怎么进入企业的网站理论上用于分类的图像一般都不需要用labelme来标注的,笔者是因为刚好手上有这么一组数据,所以就顺带处理了。labelme标注完的数据每张还包含了一个json文件,这个在分类任务中用不上。具体的mmclassification使用方法在我的另一篇文章里有&…

理论上用于分类的图像一般都不需要用labelme来标注的,笔者是因为刚好手上有这么一组数据,所以就顺带处理了。labelme标注完的数据每张还包含了一个json文件,这个在分类任务中用不上。具体的mmclassification使用方法在我的另一篇文章里有,需要注意的是现在分类任务被集合在mmpretrain里了。用法也优点区别,不过也都是细微的修改,都还能用。
数据处理代码如下:

import os, random, shutil# 最开始train的文件夹路径
ori_path = r'F:\Data\doctor_research\Arthritis_mini'# label种类:
label_list = ['arthritis', 'normal']# 抽取比例  ******自己改*******
val_ratio, test_ratio = 0.1, 0.2  # 抽取比例  ******自己改*******# 处理好的数据集路径
result_path = os.path.join(ori_path, 'result')# 存放图片的文件地址
train_path = os.path.join(result_path, 'train')
test_path = os.path.join(result_path, 'test')
val_path = os.path.join(result_path, 'val')# meta文件夹地址
meta_path = os.path.join(result_path, 'meta')
# meta文件夹下的txt文件
train_txt = os.path.join(meta_path, 'train.txt')
test_txt = os.path.join(meta_path, 'test.txt')
val_txt = os.path.join(meta_path, 'val.txt')# 预留内容
traintxt = []
testtxt = []
valtxt = []# 如果没有就创建
if not os.path.exists(result_path):os.mkdir(result_path)if not os.path.exists(meta_path):os.makedirs(meta_path)if not os.path.exists(train_path):os.makedirs(train_path)if not os.path.exists(test_path):os.makedirs(test_path)if not os.path.exists(val_path):os.makedirs(val_path)# 在train  test  val 文件夹中创建对应的label文件夹:
for label in label_list:print(f'label:{label}')os.makedirs(os.path.join(train_path, label), exist_ok=True)# print(f'train_path:{train_path}')os.makedirs(os.path.join(test_path, label), exist_ok=True)# print(f'test_path:{test_path}')os.makedirs(os.path.join(val_path, label), exist_ok=True)# print(f'val_path:{val_path}')ori_pic_path = os.path.join(ori_path, label)print(f'ori_pic_path is : {ori_pic_path}')# 将该label下所有的图像文件名暂存在一个list里面:temp_path = []for pic in os.listdir(ori_pic_path):# 判断是否为图片if pic.endswith('.jpg') or pic.endswith('.jpeg') or pic.endswith('.png'):# 先全部计入到一个临时list里:print(f'pic is {pic}')temp_path.append(pic)# print(f'temp_path is {temp_path}')# 计算该类别下的所有图片数量以及对应的验证集、测试集图片数量print(f'{label} num is {len(temp_path)}')# 验证集数量val_number = int(len(temp_path) * val_ratio)# 测试集数量test_number = int(len(temp_path) * test_ratio)# 抽取val数据集val_sample = random.sample(temp_path, val_number)print(f'val_number is:{val_number}')print(f'val_sample is:{val_sample}')# 把抽取的val数据剔除# temp_path.remove(val_sample)temp_path = [item for item in temp_path if item not in val_sample]# 对应的val文件夹:goal_val_path = os.path.join(result_path, 'val', label)# 将文件移动到val文件夹for name1 in val_sample:goal_name1_path = os.path.join(goal_val_path, name1)shutil.copy(os.path.join(ori_pic_path, name1), goal_name1_path)# 同时将该文件地址记录到val.txt中val_content = goal_name1_path + " " + str(label_list.index(label))valtxt.append(val_content)# with open(val_txt, 'w') as f:#     f.write(goal_name1_path + " " + str(label_list.index(label)) + "\n")# 抽取test数据集test_sample = random.sample(temp_path, test_number)print(f'test_number is:{test_number}')# 把抽取的test数据剔除temp_path = [item for item in temp_path if item not in test_sample]# 对应的test文件夹goal_test_path = os.path.join(result_path, 'test', label)# 将文件移动到test文件夹for name2 in test_sample:goal_name2_path = os.path.join(goal_test_path, name2)shutil.copy(os.path.join(ori_pic_path, name2), goal_name2_path)# 同时将该文件地址记录到test.txt中# 同时将该文件地址记录到test.txt中test_content = goal_name2_path + " " + str(label_list.index(label))testtxt.append(test_content)# with open(test_txt, 'w') as f:#     f.write(goal_name2_path + " " + str(label_list.index(label)) + "\n")# 把剩下的数据移入train数据集goal_train_path = os.path.join(result_path, 'train', label)print(f'goal_train_path is : {goal_train_path}')for name3 in temp_path:goal_name3_path = os.path.join(goal_train_path, name3)shutil.copy(os.path.join(ori_pic_path, name3), goal_name3_path)# 同时将该文件地址记录到test.txt中train_content = goal_name3_path + " " + str(label_list.index(label))traintxt.append(train_content)with open(train_txt, 'w') as f:for item in traintxt:f.write(item + '\n')with open(test_txt, 'w') as f:for item in testtxt:f.write(item + '\n')with open(val_txt, 'w') as f:for item in valtxt:f.write(item + '\n')
http://www.hkea.cn/news/341570/

相关文章:

  • 江苏网站建设网络推广关键词批量调词 软件
  • 东莞企业网站建设价格怎么在百度发布免费广告
  • 网站后台地址一般是在线seo优化工具
  • 海曙区住房和建设局网站备案域名
  • 网站建设硬件环境志鸿优化设计答案
  • 网页游戏网址推荐宁波网站推广网站优化
  • 福建就福建省住房与城乡建设厅网站高端网站建设企业
  • 网站如何做seo规划app怎么开发出来的
  • 吴江住房和城乡建设局官方网站产品软文是什么
  • 公司网站制作设谷歌seo是什么职业
  • 北京品牌高端网站建设公司燕郊今日头条
  • 网站制作公司徐州宁波网站seo哪家好
  • 做网站基本费用大概需要多少全媒体运营师报考官网在哪里
  • 网站建设款属于什么科目营业推广策划
  • 建设网站查证书网络广告有哪些形式
  • 分布式网站开发网络销售平台排名
  • 网站建设模板购买品牌seo培训
  • 深圳网站建设 cms网站推广交换链接
  • 标准物质网站建设5118站长工具箱
  • 做一个能注册用户的网站网络推广费用大概价格
  • 网站建设评价东莞谷歌推广
  • php网站后台进不去百度推广入口官网
  • 个人网站一键生成免费推广网站有哪些
  • 厦门做网站设计电商seo优化
  • wordpress视频点播seo技术是干什么的
  • 网站推广是怎么做的网络营销专业如何
  • 平面设计线上兼职上海网站seo
  • 个性化网站定制价格今日热点
  • 做网站的艰辛免费个人网站申请
  • 网站改版需要多久网站设计与制作毕业论文范文