赞
踩
目录
1、github上yolo的地址为
https://github.com/ultralytics/ultralytics
2、进入之后点击中文,就进入ultralytics中文文档
3、我们点击模型,进入模型页面
1、选择我们需要的模型,我这里选择YOLOV8
2、接下来就可以看到YOLOV8的模型,按需下载就行了
1、但是由于YOLOV8训练模型都在外网上,国内用户访问速度上有限制,而我们下载的时候经常性几个小时都下不下来。比如下面这张图:
1、于是我们另辟蹊径,用python脚本去下载,我们提前将需要下载的模型放入名为model的txt文件内,如下图:
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-seg.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-seg.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-seg.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-seg.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-seg.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-pose.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-pose.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-pose.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-pose.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-pose-p6.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n-cls.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s-cls.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m-cls.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l-cls.pt https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8x-cls.pt
2、再编写一个python脚本名为downloadmodel.py,内容如下:
- #!usr/bin/env python
- # encoding:utf-8
- from __future__ import division
-
- import os
- import time
- import logging
- import subprocess
- import urllib
- import requests
- import torch
- import random
- from pathlib import Path
-
- def autoDownload(filePath="model.txt", downloadDir="model/yolov8/"):
- if not os.path.exists(downloadDir):
- os.makedirs(downloadDir)
- while True:
- with open(filePath) as f:
- lists = [one.strip() for one in f.readlines() if one.strip()]
- count = 0
- for downloadUrl in lists:
- print("模型下载地址: ", downloadUrl)
- try:
- tmpFile = downloadDir + downloadUrl.split("/")[-1].strip()
- print("下载文件路径: ", tmpFile)
- if not os.path.exists(tmpFile):
- torch.hub.download_url_to_file(downloadUrl, str(tmpFile))
- else:
- print("当前训练模型文件已经下载完成!")
- count += 1
- except Exception as e:
- print("Exception: ", e)
- time.sleep(random.randint(1, 5))
- print("下载数量为: ", count)
- if count == len(lists):
- break
-
- if __name__ == "__main__":
-
- autoDownload(filePath="model.txt", downloadDir="model/")
3、脚本文件和txt模型地址文件放在任意目录
4、cmd命令进入脚本文件所在目录,输入如下命令
python downloadmodel.py
脚本文件就会自动给你下载,你就可以解放双手和眼睛了,等着它慢慢下完即可
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。