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

南阳建网站企业北京网站seo优化推广

南阳建网站企业,北京网站seo优化推广,phpcms网站模板下载,校园网络平台建设方案时代在进步,yolo在进步,我还在踏步,v8我浅搞了一下detect和pose,记录一下,我还是要吐槽一下,为啥子这个模型就放在了这个文件深处,如图。 以下教程只应用于直接应用yolov8,不修改。…

       时代在进步,yolo在进步,我还在踏步,v8我浅搞了一下detect和pose,记录一下,我还是要吐槽一下,为啥子这个模型就放在了这个文件深处,如图。

以下教程只应用于直接应用yolov8,不修改。我之前搞v7的环境,直接

 pip install ultralytics

1. detect

       在detect文件夹下新建一个dataset放图片(jpg)和yolo格式的标签(txt)训练集和测试集直接分好,再新建一个data.yaml,如图,放你自己的路径,类别。

放一个检测框的json转yolo的代码,改类别和文件夹路径

import os
import json
import numpy as np
# 类和索引
CLASSES=["fish"]
def convert(size,box):'''''input:size:(width,height);box:(x1,x2,y1,y2)output:(x,y,w,h)'''dw=1./size[0]dh=1./size[1]x=(box[0]+box[1])/2.0y=(box[2]+box[3])/2.0w=box[1]-box[0]h=box[3]-box[2]x=x*dww=w*dwy=y*dhh=h*dhreturn (x,y,w,h)
# json -> txt
def json2txt(path_json,path_txt):# print(path_json,"r")with open(path_json,"r") as path_json:jsonx=json.load(path_json)width=int(jsonx["imageWidth"])      # 原图的宽height=int(jsonx["imageHeight"])    # 原图的高with open(path_txt,"w+") as ftxt:# 遍历每一个bbox对象for shape in jsonx["shapes"]:obj_cls=str(shape["label"])     # 获取类别cls_id=CLASSES.index(obj_cls)   # 获取类别索引points=np.array(shape["points"])    # 获取(x1,y1,x2,y2)x1=int(points[0][0])y1=int(points[0][1])x2=int(points[1][0])y2=int(points[1][1])# (左上角,右下角) -> (中心点,宽高) 归一化bb=convert((width,height),(x1,x2,y1,y2))ftxt.write(str(cls_id)+" "+" ".join([str(a) for a in bb])+"\n")
if __name__=="__main__":# json文件夹dir_json="C:\\Users\\ASUS\\Desktop\\111\\"# txt文件夹dir_txt="C:\\Users\\ASUS\\Desktop\\222\\"if not os.path.exists(dir_txt):os.makedirs(dir_txt)# 得到所有json文件list_json=os.listdir(dir_json)# 遍历每一个json文件,转成txt文件for cnt,json_name in enumerate(list_json):print("cnt=%d,name=%s"%(cnt,json_name))path_txt=dir_txt+json_name.replace(".json",".txt")path_json = dir_json + json_nameprint("path_json\t",path_json)print("path_txt\t",path_txt)# (x1,y1,x2,y2)->(x,y,w,h)json2txt(path_json,path_txt)

         准备好了,直接terminal里输入就行,但是如果想改点啥比如说希望预测的时候不输出的类别,就输出框,他就改不了,因为这个ultra这个包都给整好了,封装的忒严重,想在这个模型上进行改进就得给他卸了,然后再搞。

#训练的代码
yolo task=detect mode=train model=yolov8s.yaml data=D:/DATA/ultralytics-main/ultralytics/models/yolo/detect/data.yaml epochs=200 batch=128# 预测的代码
yolo task=detect mode=predict model=D:/DATA/ultralytics-main/weights/best.pt source=D:/DATA/ultralytics-main/ultralytics/models/yolo/detect/dataset/images/val  device=cpu

2. pose

       pose的数据集跟之前的有一点区别,首先标注关键点时,要先使用矩形框(rectangle)框出目标,然后在这个矩形框里面打关键点,必须保证每一张照片当中点的数量是相同的,就是说1234得对应上,每个点按顺序进行标注,总数需要是一样多的。3可以被遮挡,但是也得标,然后把这个点变成不可见就可以了。最终得到了 .json 文件,然后我们需要将其转化为 .txt 文件,2代表可见,0代表不可见。转的代码在下面,我用是好使的。

       然后跟上面差不多的命令就可以了。

# 关键点检测json转txt
import os
import json
import shutil
import timeimport numpy as np
from tqdm import tqdmDataset_root = 'C:/Users/ASUS/Desktop/strong121/labels/'  # 转化的json文件地址
# 框的类别
bbox_class =["fish"]# 关键点的类别,有多少类就写多少
keypoint_class = ['1', '2', '3','4', '5', '6', '7', '8', '9', '10', '11', '12','13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23','24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34','35', '36', '37', '38', '39', '40', '41', '42', '43', '44']os.chdir(Dataset_root)def process_single_json(labelme_path, save_folder='C:/Users/ASUS/Desktop/no/'):with open(labelme_path, 'r', encoding='utf-8') as f:labelme = json.load(f)img_width = labelme['imageWidth']  # 图像宽度img_height = labelme['imageHeight']  # 图像高度# 生成 YOLO 格式的 txt 文件suffix = labelme_path.split('.')[-2]yolo_txt_path = suffix + '.txt'with open(yolo_txt_path, 'w', encoding='utf-8') as f:for each_ann in labelme['shapes']:  # 遍历每个标注if each_ann['shape_type'] == 'rectangle':  # 每个框,在 txt 里写一行yolo_str = ''## 框的信息# 框的类别 IDbbox_class_id = bbox_class.index(each_ann['label'])# print(bbox_class_id)yolo_str += '{} '.format(bbox_class_id)# 左上角和右下角的 XY 像素坐标bbox_top_left_x = int(min(each_ann['points'][0][0], each_ann['points'][1][0]))bbox_bottom_right_x = int(max(each_ann['points'][0][0], each_ann['points'][1][0]))bbox_top_left_y = int(min(each_ann['points'][0][1], each_ann['points'][1][1]))bbox_bottom_right_y = int(max(each_ann['points'][0][1], each_ann['points'][1][1]))# 框中心点的 XY 像素坐标bbox_center_x = int((bbox_top_left_x + bbox_bottom_right_x) / 2)bbox_center_y = int((bbox_top_left_y + bbox_bottom_right_y) / 2)# 框宽度bbox_width = bbox_bottom_right_x - bbox_top_left_x# 框高度bbox_height = bbox_bottom_right_y - bbox_top_left_y# 框中心点归一化坐标bbox_center_x_norm = bbox_center_x / img_widthbbox_center_y_norm = bbox_center_y / img_height# 框归一化宽度bbox_width_norm = bbox_width / img_width# 框归一化高度bbox_height_norm = bbox_height / img_heightyolo_str += '{:.5f} {:.5f} {:.5f} {:.5f} '.format(bbox_center_x_norm, bbox_center_y_norm,bbox_width_norm, bbox_height_norm)# print(yolo_str)# print("**********************")# time.sleep(90000)## 找到该框中所有关键点,存在字典 bbox_keypoints_dict 中bbox_keypoints_dict = {}for each_ann in labelme['shapes']:  # 遍历所有标注if each_ann['shape_type'] == 'point':  # 筛选出关键点标注# 关键点XY坐标、类别x = int(each_ann['points'][0][0])y = int(each_ann['points'][0][1])label = each_ann['label']if (x > bbox_top_left_x) & (x < bbox_bottom_right_x) & (y < bbox_bottom_right_y) & (y > bbox_top_left_y):  # 筛选出在该个体框中的关键点bbox_keypoints_dict[label] = [x, y]## 把关键点按顺序排好for each_class in keypoint_class:  # 遍历每一类关键点if each_class in bbox_keypoints_dict:keypoint_x_norm = bbox_keypoints_dict[each_class][0] / img_widthkeypoint_y_norm = bbox_keypoints_dict[each_class][1] / img_heightyolo_str += '{:.5f} {:.5f} {} '.format(keypoint_x_norm, keypoint_y_norm,2)  # 2-可见不遮挡 1-遮挡 0-没有点else:  # 不存在的点,一律为0yolo_str += '0 0 0 '# 写入 txt 文件中f.write(yolo_str + '\n')shutil.move(yolo_txt_path, save_folder)print('{} --> {} 转换完成'.format(labelme_path, yolo_txt_path))save_folder = 'C:/Users/ASUS/Desktop/no'   #  转换后的训练集标注文件至目录
for labelme_path in os.listdir(Dataset_root):# try:process_single_json(Dataset_root + labelme_path, save_folder=save_folder)# except:#     print('******有误******', labelme_path)
print('YOLO格式的txt标注文件已保存至 ', save_folder)


文章转载自:
http://babble.mnqg.cn
http://libeccio.mnqg.cn
http://retailer.mnqg.cn
http://fopling.mnqg.cn
http://cyclicity.mnqg.cn
http://nizam.mnqg.cn
http://amortisement.mnqg.cn
http://chelator.mnqg.cn
http://rigoroso.mnqg.cn
http://salinometer.mnqg.cn
http://astarboard.mnqg.cn
http://bok.mnqg.cn
http://hysterectomize.mnqg.cn
http://convent.mnqg.cn
http://radiogold.mnqg.cn
http://assault.mnqg.cn
http://aminotriazole.mnqg.cn
http://oup.mnqg.cn
http://consigner.mnqg.cn
http://honestly.mnqg.cn
http://understructure.mnqg.cn
http://radiogoniometer.mnqg.cn
http://auriga.mnqg.cn
http://intersexuality.mnqg.cn
http://quadrangle.mnqg.cn
http://garcinia.mnqg.cn
http://acetanilid.mnqg.cn
http://pacesetter.mnqg.cn
http://cete.mnqg.cn
http://deanna.mnqg.cn
http://tetrachlorethane.mnqg.cn
http://diamagnetize.mnqg.cn
http://retral.mnqg.cn
http://aforesaid.mnqg.cn
http://ceraunograph.mnqg.cn
http://liberally.mnqg.cn
http://decipherment.mnqg.cn
http://jampan.mnqg.cn
http://retaliative.mnqg.cn
http://nonpeak.mnqg.cn
http://apriorism.mnqg.cn
http://confederative.mnqg.cn
http://bugbear.mnqg.cn
http://mogilalia.mnqg.cn
http://interknot.mnqg.cn
http://interzone.mnqg.cn
http://noodle.mnqg.cn
http://lacquey.mnqg.cn
http://drury.mnqg.cn
http://enanthema.mnqg.cn
http://unneutrality.mnqg.cn
http://idiosyncrasy.mnqg.cn
http://harmonist.mnqg.cn
http://casket.mnqg.cn
http://relocatee.mnqg.cn
http://subtility.mnqg.cn
http://dhtml.mnqg.cn
http://contrate.mnqg.cn
http://domaine.mnqg.cn
http://ormuz.mnqg.cn
http://interterritorial.mnqg.cn
http://kerria.mnqg.cn
http://beechen.mnqg.cn
http://fimbria.mnqg.cn
http://tit.mnqg.cn
http://enhearten.mnqg.cn
http://seafolk.mnqg.cn
http://madrigal.mnqg.cn
http://conferral.mnqg.cn
http://hypersphere.mnqg.cn
http://misconstrue.mnqg.cn
http://baseballer.mnqg.cn
http://coastal.mnqg.cn
http://boney.mnqg.cn
http://woomera.mnqg.cn
http://denticule.mnqg.cn
http://ged.mnqg.cn
http://mussy.mnqg.cn
http://analcime.mnqg.cn
http://bebop.mnqg.cn
http://bitewing.mnqg.cn
http://questionless.mnqg.cn
http://semiglazed.mnqg.cn
http://enlist.mnqg.cn
http://deave.mnqg.cn
http://benignancy.mnqg.cn
http://zante.mnqg.cn
http://kissably.mnqg.cn
http://buckinghamshire.mnqg.cn
http://ussuriisk.mnqg.cn
http://astigmatoscope.mnqg.cn
http://astucious.mnqg.cn
http://reticently.mnqg.cn
http://heterostructure.mnqg.cn
http://wigan.mnqg.cn
http://lancers.mnqg.cn
http://unclasp.mnqg.cn
http://neuroleptic.mnqg.cn
http://deprivation.mnqg.cn
http://nasally.mnqg.cn
http://www.dt0577.cn/news/65280.html

相关文章:

  • 中企网络科技建站优化营商环境心得体会
  • 小说阅读网站开发设计正规电商培训班
  • 南宁制作网站会计培训班一般多少钱
  • 重庆大足网站制作公司哪家专业湖南网站推广
  • 自己做的网站网页滑动不seo排名赚app靠谱吗
  • 纯html css做的网站seo知识分享
  • 获取网站访客qq号百度收录批量查询
  • 上线了做的网站可以登陆湖北百度推广公司
  • 南安梅山建设银行网站优化大师电脑版官网
  • 高端网站建设 炫酷百度官网认证入口
  • 网站建设如何做报价百度收录什么意思
  • wordpress设置自动登陆太原seo优化公司
  • 做外贸网站报价单公众号软文推广
  • 手机在线做网站百度2022最新版本
  • 长沙品牌网站建设信息推广服务
  • 网站建设的id调用怎么操作b站推广网站入口2023是什么
  • 用excel做网站网站推广推广
  • 网上做批发的网站有哪些百度allin 人工智能
  • php 网站 上传到空间网站推广的基本方法是
  • 360网站卫士 真实ip谷歌seo靠谱吗
  • 如何建立小企业网站杭州seo渠道排名
  • 学校网站建设网络推广视频
  • 大访问量的网站怎么做优化产品推广软文范文
  • 网站搜索功能怎样做杭州网络优化公司排名
  • 做代刷网站赚钱不公司网站模版
  • 欧美风格外贸网站建设网站流量数据分析
  • 如何建立一个网站及app抖音排名优化
  • 做动漫网站侵权吗友情链接官网
  • 相亲网站用什么做的市场监督管理局官网入口
  • 做网站一定要用到dw怎么网上推广自己的产品