中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

如何做直播網(wǎng)站有沒有專門幫人推廣的公司

如何做直播網(wǎng)站,有沒有專門幫人推廣的公司,web開發(fā)是做網(wǎng)站,南山免費(fèi)做網(wǎng)站公司排名文章目錄 前言一、環(huán)境搭建必要環(huán)境1. 創(chuàng)建yolov10虛擬環(huán)境2. 下載pytorch (pytorch版本>1.8)3. 下載YOLOv10源碼4. 安裝所需要的依賴包 二、推理測試1. 將如下代碼復(fù)制到ultralytics文件夾同級目錄下并運(yùn)行 即可得到推理結(jié)果2. 關(guān)鍵參數(shù) 三、訓(xùn)練及評估1. 數(shù)據(jù)結(jié)構(gòu)介紹2. 配…

文章目錄

  • 前言
  • 一、環(huán)境搭建
    • 必要環(huán)境
    • 1. 創(chuàng)建yolov10虛擬環(huán)境
    • 2. 下載pytorch (pytorch版本>=1.8)
    • 3. 下載YOLOv10源碼
    • 4. 安裝所需要的依賴包
  • 二、推理測試
    • 1. 將如下代碼復(fù)制到ultralytics文件夾同級目錄下并運(yùn)行 即可得到推理結(jié)果
    • 2. 關(guān)鍵參數(shù)
  • 三、訓(xùn)練及評估
    • 1. 數(shù)據(jù)結(jié)構(gòu)介紹
    • 2. 配置文件修改
    • 3. 訓(xùn)練/評估模型
    • 4. 關(guān)鍵參數(shù)
    • 5. 單獨(dú)對訓(xùn)練好的模型將進(jìn)行評估
  • 總結(jié)


前言

本文將詳細(xì)介紹跑通YOLOv10的流程,并給各位提供用于訓(xùn)練、評估和模型推理的腳本

一、環(huán)境搭建

必要環(huán)境

本文使用Windows10+Python3.8+CUDA10.2+CUDNN8.0.4作為基礎(chǔ)環(huán)境,使用30系或40系顯卡的小伙伴請安裝11.0以上版本的CUDA

1. 創(chuàng)建yolov10虛擬環(huán)境

conda create -n yolov10 python=3.8

2. 下載pytorch (pytorch版本>=1.8)

pip install torch==1.9.1+cu102 torchvision==0.10.1+cu102 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

若使用的是AMD顯卡或不使用GPU的同學(xué) 可以通過以下命令可以安裝CPU版本

pip install torch==1.9.1+cpu torchvision==0.10.1+cpu torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

3. 下載YOLOv10源碼

地址:https://github.com/THU-MIG/yolov10

4. 安裝所需要的依賴包

pip install -r requirements.txt

二、推理測試

1. 將如下代碼復(fù)制到ultralytics文件夾同級目錄下并運(yùn)行 即可得到推理結(jié)果

import cv2
from ultralytics import YOLOv10
import os
import argparse
import time
import torchparser = argparse.ArgumentParser()
# 檢測參數(shù)
parser.add_argument('--weights', default=r"yolov10n.pt", type=str, help='weights path')
parser.add_argument('--source', default=r"images", type=str, help='img or video(.mp4)path')
parser.add_argument('--save', default=r"./save", type=str, help='save img or video path')
parser.add_argument('--vis', default=True, action='store_true', help='visualize image')
parser.add_argument('--conf_thre', type=float, default=0.5, help='conf_thre')
parser.add_argument('--iou_thre', type=float, default=0.5, help='iou_thre')
opt = parser.parse_args()
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')def get_color(idx):idx = idx * 3color = ((37 * idx) % 255, (17 * idx) % 255, (29 * idx) % 255)return colorclass Detector(object):def __init__(self, weight_path, conf_threshold=0.5, iou_threshold=0.5):self.device = deviceself.model = YOLOv10(weight_path)self.conf_threshold = conf_thresholdself.iou_threshold = iou_thresholdself.names = {0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus', 6: 'train',7: 'truck', 8: 'boat', 9: 'traffic light', 10: 'fire hydrant', 11: 'stop sign',12: 'parking meter', 13: 'bench', 14: 'bird', 15: 'cat', 16: 'dog', 17: 'horse', 18: 'sheep',19: 'cow', 20: 'elephant', 21: 'bear', 22: 'zebra', 23: 'giraffe', 24: 'backpack', 25: 'umbrella',26: 'handbag', 27: 'tie', 28: 'suitcase', 29: 'frisbee', 30: 'skis', 31: 'snowboard',32: 'sports ball', 33: 'kite', 34: 'baseball bat', 35: 'baseball glove', 36: 'skateboard',37: 'surfboard', 38: 'tennis racket', 39: 'bottle', 40: 'wine glass', 41: 'cup', 42: 'fork',43: 'knife', 44: 'spoon', 45: 'bowl', 46: 'banana', 47: 'apple', 48: 'sandwich', 49: 'orange',50: 'broccoli', 51: 'carrot', 52: 'hot dog', 53: 'pizza', 54: 'donut', 55: 'cake', 56: 'chair',57: 'couch', 58: 'potted plant', 59: 'bed', 60: 'dining table', 61: 'toilet', 62: 'tv',63: 'laptop', 64: 'mouse', 65: 'remote', 66: 'keyboard', 67: 'cell phone', 68: 'microwave',69: 'oven', 70: 'toaster', 71: 'sink', 72: 'refrigerator', 73: 'book', 74: 'clock', 75: 'vase',76: 'scissors', 77: 'teddy bear', 78: 'hair drier', 79: 'toothbrush'}def detect_image(self, img_bgr):results = self.model(img_bgr, verbose=True, conf=self.conf_threshold,iou=self.iou_threshold, device=self.device)bboxes_cls = results[0].boxes.clsbboxes_conf = results[0].boxes.confbboxes_xyxy = results[0].boxes.xyxy.cpu().numpy().astype('uint32')for idx in range(len(bboxes_cls)):box_cls = int(bboxes_cls[idx])bbox_xyxy = bboxes_xyxy[idx]bbox_label = self.names[box_cls]box_conf = f"{bboxes_conf[idx]:.2f}"xmax, ymax, xmin, ymin = bbox_xyxy[2], bbox_xyxy[3], bbox_xyxy[0], bbox_xyxy[1]img_bgr = cv2.rectangle(img_bgr, (xmin, ymin), (xmax, ymax), get_color(box_cls + 3), 2)cv2.putText(img_bgr, f'{str(bbox_label)}/{str(box_conf)}', (xmin, ymin - 10),cv2.FONT_HERSHEY_SIMPLEX, 0.5, get_color(box_cls + 3), 2)return img_bgr# Example usage
if __name__ == '__main__':model = Detector(weight_path=opt.weights, conf_threshold=opt.conf_thre, iou_threshold=opt.iou_thre)images_format = ['.png', '.jpg', '.jpeg', '.JPG', '.PNG', '.JPEG']video_format = ['mov', 'MOV', 'mp4', 'MP4']if os.path.join(opt.source).split(".")[-1] not in video_format:image_names = [name for name in os.listdir(opt.source) for item in images_format ifos.path.splitext(name)[1] == item]for img_name in image_names:img_path = os.path.join(opt.source, img_name)img_ori = cv2.imread(img_path)img_vis = model.detect_image(img_ori)img_vis = cv2.resize(img_vis, None, fx=1.0, fy=1.0, interpolation=cv2.INTER_NEAREST)cv2.imwrite(os.path.join(opt.save, img_name), img_vis)if opt.vis:cv2.imshow(img_name, img_vis)cv2.waitKey(0)cv2.destroyAllWindows()else:capture = cv2.VideoCapture(opt.source)fps = capture.get(cv2.CAP_PROP_FPS)size = (int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)),int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)))fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')outVideo = cv2.VideoWriter(os.path.join(opt.save, os.path.basename(opt.source).split('.')[-2] + "_out.mp4"),fourcc,fps, size)while True:ret, frame = capture.read()if not ret:breakstart_frame_time = time.perf_counter()img_vis = model.detect_image(frame)# 結(jié)束計(jì)時(shí)end_frame_time = time.perf_counter()  # 使用perf_counter進(jìn)行時(shí)間記錄# 計(jì)算每幀處理的FPSelapsed_time = end_frame_time - start_frame_timeif elapsed_time == 0:fps_estimation = 0.0else:fps_estimation = 1 / elapsed_timeh, w, c = img_vis.shapecv2.putText(img_vis, f"FPS: {fps_estimation:.2f}", (10, 35), cv2.FONT_HERSHEY_SIMPLEX, 1.3, (0, 0, 255), 2)outVideo.write(img_vis)cv2.imshow('detect', img_vis)cv2.waitKey(1)capture.release()outVideo.release()

2. 關(guān)鍵參數(shù)

1. 測試圖片:–source 變量后填寫圖像文件夾路徑 如:default=r"images"
2. 測試視頻:–source 變量后填寫視頻路徑 如:default=r"video.mp4"

推理圖像效果:
在這里插入圖片描述

推理視頻效果:在這里插入圖片描述

三、訓(xùn)練及評估

1. 數(shù)據(jù)結(jié)構(gòu)介紹

這里使用的數(shù)據(jù)集是VOC2007,用留出法將數(shù)據(jù)按9:1的比例劃分成了訓(xùn)練集和驗(yàn)證集
在這里插入圖片描述
下載地址如下:
鏈接:https://pan.baidu.com/s/1FmbShVF1SQOZfjncj3OKJA?pwd=i7od
提取碼:i7od

2. 配置文件修改

在這里插入圖片描述

3. 訓(xùn)練/評估模型

將如下代碼復(fù)制到ultralytics文件夾同級目錄下并運(yùn)行 即可開始訓(xùn)練

# -*- coding:utf-8 -*-
from ultralytics import YOLOv10
import argparse# 解析命令行參數(shù)
parser = argparse.ArgumentParser(description='Train or validate YOLO model.')
# train用于訓(xùn)練原始模型  val 用于得到精度指標(biāo)
parser.add_argument('--mode', type=str, default='train', help='Mode of operation.')
# 預(yù)訓(xùn)練模型
parser.add_argument('--weights', type=str, default='yolov10n.pt', help='Path to model file.')
# 數(shù)據(jù)集存放路徑
parser.add_argument('--data', type=str, default='VOC2007/data.yaml', help='Path to data file.')
parser.add_argument('--epoch', type=int, default=200, help='Number of epochs.')
parser.add_argument('--batch', type=int, default=8, help='Batch size.')
parser.add_argument('--workers', type=int, default=0, help='Number of workers.')
parser.add_argument('--device', type=str, default='0', help='Device to use.')
parser.add_argument('--name', type=str, default='', help='Name data file.')
args = parser.parse_args()def train(model, data, epoch, batch, workers, device, name):model.train(data=data, epochs=epoch, batch=batch, workers=workers, device=device, name=name)def validate(model, data, batch, workers, device, name):model.val(data=data, batch=batch, workers=workers, device=device, name=name)def main():model = YOLOv10(args.weights)if args.mode == 'train':train(model, args.data, args.epoch, args.batch, args.workers, args.device, args.name)else:validate(model, args.data, args.batch, args.workers, args.device, args.name)if __name__ == '__main__':main()

4. 關(guān)鍵參數(shù)

1. 模式選擇:
–mode train: 開始訓(xùn)練模型
–mode val: 進(jìn)行模型驗(yàn)證

2. 訓(xùn)練輪數(shù): 通過 --epoch 參數(shù)設(shè)置訓(xùn)練輪數(shù),默認(rèn)為200輪。該參數(shù)控制模型在訓(xùn)練集上迭代的次數(shù),增加輪數(shù)有助于提升模型性能,但同時(shí)也會增加訓(xùn)練時(shí)間。

3. 訓(xùn)練批次: 通過 --batch 參數(shù)設(shè)置訓(xùn)練批次大小,一般設(shè)置為2的倍數(shù),如8或16。批次大小決定了每次參數(shù)更新時(shí)使用的樣本數(shù)量,較大的批次有助于加速收斂,但會增加顯存占用,需根據(jù)實(shí)際顯存大小進(jìn)行調(diào)整

4. 訓(xùn)練數(shù)據(jù)加載進(jìn)程數(shù): 通過 --workers 參數(shù)設(shè)置數(shù)據(jù)加載進(jìn)程數(shù),默認(rèn)為8。該參數(shù)控制了在訓(xùn)練期間用于加載和預(yù)處理數(shù)據(jù)的進(jìn)程數(shù)量。增加進(jìn)程數(shù)可以加快數(shù)據(jù)的加載速度,linux系統(tǒng)下一般設(shè)置為8或16,windows系統(tǒng)設(shè)置為0。

訓(xùn)練過程:在這里插入圖片描述
訓(xùn)練結(jié)束后模型已經(jīng)訓(xùn)練過程默認(rèn)會保存到runs/detect/exp路徑下

5. 單獨(dú)對訓(xùn)練好的模型將進(jìn)行評估

1. 將 --mode變量后改為val 如:default=“val”
2. 將 --weights變量后改為要單獨(dú)評估的模型路徑 如:default=r"runs/detect/exp/weights/best.pt"

評估過程:
在這里插入圖片描述


總結(jié)

yolo是真卷吶,版本號一會兒一變的,v9還沒看呢v10已經(jīng)出來了…

最近經(jīng)常在b站上更新一些有關(guān)目標(biāo)檢測的視頻,大家感興趣可以來看看 https://b23.tv/1upjbcG

學(xué)習(xí)交流群:995760755


http://www.risenshineclean.com/news/3443.html

相關(guān)文章:

  • 上海專業(yè)網(wǎng)站建設(shè)公司電話四川seo多少錢
  • 自己做的網(wǎng)站怎么掛廣告上海百度推廣開戶
  • 東莞廣告公司有哪些長沙seo優(yōu)化公司
  • 北京多用戶商城網(wǎng)站建設(shè)百度愛采購優(yōu)化排名軟件
  • 幫人做網(wǎng)站一個(gè)多少錢網(wǎng)站在線推廣
  • 免費(fèi)企業(yè)網(wǎng)站模板psd站長之家是干什么的
  • 南通快速建站公司公司建網(wǎng)站多少錢
  • 南寧建設(shè)廳網(wǎng)站是什么效果好的關(guān)鍵詞如何優(yōu)化
  • 百度指數(shù)官網(wǎng)入口網(wǎng)站在線優(yōu)化檢測
  • 百度地圖排名怎么優(yōu)化優(yōu)化營商環(huán)境發(fā)言材料
  • 東莞網(wǎng)站包年優(yōu)化百度圖片識別在線使用
  • 政府網(wǎng)站的做東莞關(guān)鍵詞排名提升
  • app圖標(biāo)制作seo門戶
  • 國家質(zhì)檢總局網(wǎng)站品牌建設(shè)河南省干部任免最新公示
  • wordpress 分享到朋友圈開封seo公司
  • 簡述電子商務(wù)網(wǎng)站開發(fā)的基本原則網(wǎng)站下載
  • 珠海建設(shè)網(wǎng)站的公司簡介百度一下你就知道百度首頁
  • wordpress被百度收錄百度自然排名優(yōu)化
  • 自己做網(wǎng)站還是找網(wǎng)站建設(shè)公司好網(wǎng)站公司
  • 如何分析網(wǎng)站功能seo全稱英文怎么說
  • 網(wǎng)站注冊免費(fèi)網(wǎng)絡(luò)輿情報(bào)告
  • 便宜電商網(wǎng)站建設(shè)關(guān)鍵詞林俊杰在線聽免費(fèi)
  • 做網(wǎng)站好多錢免費(fèi)網(wǎng)站代理訪問
  • 制作網(wǎng)站參考案例廣州優(yōu)化疫情防控舉措
  • 杭州怎么做網(wǎng)站今日新聞頭條熱點(diǎn)
  • wordpress 插件 支付搜索引擎關(guān)鍵詞優(yōu)化有哪些技巧
  • 離石做網(wǎng)站的公司做網(wǎng)絡(luò)推廣可以通過哪些渠道推廣
  • 門戶網(wǎng)站的建設(shè)思路百度網(wǎng)站排名怎么提高
  • 企業(yè)免費(fèi)網(wǎng)站系統(tǒng)下載地址百度競價(jià)推廣什么意思
  • wordpress原始分頁共seo關(guān)鍵詞優(yōu)化費(fèi)用