@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="py39" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="GOOGLE" />
|
||||
<option name="myDocStringFormat" value="Google" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,20 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="7">
|
||||
<item index="0" class="java.lang.String" itemvalue="torch" />
|
||||
<item index="1" class="java.lang.String" itemvalue="torchvision" />
|
||||
<item index="2" class="java.lang.String" itemvalue="seaborn" />
|
||||
<item index="3" class="java.lang.String" itemvalue="thop" />
|
||||
<item index="4" class="java.lang.String" itemvalue="matplotlib" />
|
||||
<item index="5" class="java.lang.String" itemvalue="pyqt5-tools" />
|
||||
<item index="6" class="java.lang.String" itemvalue="ultralytics" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="py39" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/YOLOv8face.iml" filepath="$PROJECT_DIR$/.idea/YOLOv8face.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,20 @@
|
||||
cff-version: 1.2.0
|
||||
preferred-citation:
|
||||
type: software
|
||||
message: If you use this software, please cite it as below.
|
||||
authors:
|
||||
- family-names: Jocher
|
||||
given-names: Glenn
|
||||
orcid: "https://orcid.org/0000-0001-5950-6979"
|
||||
- family-names: Chaurasia
|
||||
given-names: Ayush
|
||||
orcid: "https://orcid.org/0000-0002-7603-6750"
|
||||
- family-names: Qiu
|
||||
given-names: Jing
|
||||
orcid: "https://orcid.org/0000-0003-3783-7069"
|
||||
title: "YOLO by Ultralytics"
|
||||
version: 8.0.0
|
||||
# doi: 10.5281/zenodo.3908559 # TODO
|
||||
date-released: 2023-1-10
|
||||
license: AGPL-3.0
|
||||
url: "https://github.com/ultralytics/ultralytics"
|
@ -0,0 +1,46 @@
|
||||
#coding:utf-8
|
||||
import cv2
|
||||
from ultralytics import YOLO
|
||||
|
||||
# 所需加载的模型目录
|
||||
path = 'models/best.pt'
|
||||
|
||||
# Load the YOLOv8 model
|
||||
model = YOLO(path)
|
||||
|
||||
ID = 0
|
||||
while(ID<10):
|
||||
cap = cv2.VideoCapture(ID)
|
||||
# get a frame
|
||||
ret, frame = cap.read()
|
||||
if ret == False:
|
||||
ID += 1
|
||||
else:
|
||||
print('摄像头ID:',ID)
|
||||
break
|
||||
|
||||
# Loop through the video frames
|
||||
while cap.isOpened():
|
||||
# Read a frame from the video
|
||||
success, frame = cap.read()
|
||||
|
||||
if success:
|
||||
# Run YOLOv8 inference on the frame
|
||||
results = model(frame)
|
||||
|
||||
# Visualize the results on the frame
|
||||
annotated_frame = results[0].plot()
|
||||
|
||||
# Display the annotated frame
|
||||
cv2.imshow("YOLOv8 Inference", annotated_frame)
|
||||
|
||||
# Break the loop if 'q' is pressed
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
else:
|
||||
# Break the loop if the end of the video is reached
|
||||
break
|
||||
|
||||
# Release the video capture object and close the display window
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
@ -0,0 +1,9 @@
|
||||
#coding:utf-8
|
||||
|
||||
# 图片及视频检测结果保存路径
|
||||
save_path = 'save_data'
|
||||
|
||||
# 使用的模型路径
|
||||
model_path = 'models/best.pt'
|
||||
names = {0: 'face'}
|
||||
CH_names = ['人脸']
|
After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 144 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 964 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 203 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 2.1 MiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 25 KiB |
@ -0,0 +1,37 @@
|
||||
#coding:utf-8
|
||||
import cv2
|
||||
from ultralytics import YOLO
|
||||
|
||||
# 所需加载的模型目录
|
||||
path = 'models/best.pt'
|
||||
# 需要检测的图片地址
|
||||
video_path = "TestFiles/1.mp4"
|
||||
|
||||
# Load the YOLOv8 model
|
||||
model = YOLO(path)
|
||||
cap = cv2.VideoCapture(video_path)
|
||||
# Loop through the video frames
|
||||
while cap.isOpened():
|
||||
# Read a frame from the video
|
||||
success, frame = cap.read()
|
||||
|
||||
if success:
|
||||
# Run YOLOv8 inference on the frame
|
||||
results = model(frame)
|
||||
|
||||
# Visualize the results on the frame
|
||||
annotated_frame = results[0].plot()
|
||||
|
||||
# Display the annotated frame
|
||||
cv2.imshow("YOLOv8 Inference", annotated_frame)
|
||||
|
||||
# Break the loop if 'q' is pressed
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
break
|
||||
else:
|
||||
# Break the loop if the end of the video is reached
|
||||
break
|
||||
|
||||
# Release the video capture object and close the display window
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
@ -0,0 +1,21 @@
|
||||
#coding:utf-8
|
||||
from ultralytics import YOLO
|
||||
import cv2
|
||||
|
||||
# 所需加载的模型目录
|
||||
path = 'models/best.pt'
|
||||
# 需要检测的图片地址
|
||||
img_path = "TestFiles/test4.jpg"
|
||||
|
||||
# 加载预训练模型
|
||||
# conf 0.25 object confidence threshold for detection
|
||||
# iou 0.7 intersection over union (IoU) threshold for NMS
|
||||
model = YOLO(path, task='detect')
|
||||
# model = YOLO(path, task='detect',conf=0.5)
|
||||
|
||||
|
||||
# 检测图片
|
||||
results = model(img_path)
|
||||
res = results[0].plot()
|
||||
cv2.imshow("YOLOv8 Detection", res)
|
||||
cv2.waitKey(0)
|
@ -0,0 +1,7 @@
|
||||
import os
|
||||
|
||||
pkgs = ['ultralytics','PyQt5==5.15.2','pyqt5-tools==5.15.2.3.1']
|
||||
|
||||
for each in pkgs:
|
||||
cmd_line = f"pip install {each} -i https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
os.system(cmd_line)
|
@ -0,0 +1,5 @@
|
||||
import torch
|
||||
print(torch.cuda.is_available())
|
||||
print(torch.backends.cudnn.is_available())
|
||||
print(torch.cuda_version)
|
||||
print(torch.backends.cudnn.version())
|
@ -0,0 +1,31 @@
|
||||
certifi==2023.7.22
|
||||
charset-normalizer==3.3.0
|
||||
colorama==0.4.6
|
||||
contourpy==1.1.1
|
||||
cycler==0.12.1
|
||||
fonttools==4.43.1
|
||||
idna==3.4
|
||||
importlib-resources==6.1.0
|
||||
kiwisolver==1.4.5
|
||||
matplotlib==3.8.0
|
||||
numpy==1.26.1
|
||||
opencv-python==4.8.1.78
|
||||
packaging==23.2
|
||||
psutil==5.9.6
|
||||
py-cpuinfo==9.0.0
|
||||
pyparsing==3.1.1
|
||||
python-dateutil==2.8.2
|
||||
pyyaml==6.0.1
|
||||
requests==2.31.0
|
||||
scipy==1.11.3
|
||||
seaborn==0.13.0
|
||||
six==1.16.0
|
||||
thop==0.1.1-2209072238
|
||||
# torch==1.9.0
|
||||
tqdm==4.66.1
|
||||
typing-extensions==4.8.0
|
||||
ultralytics==8.0.199
|
||||
urllib3==2.0.6
|
||||
zipp==3.17.0
|
||||
PyQt5==5.15.2
|
||||
pyqt5-tools==5.15.2.3.1
|
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 92 KiB |
@ -0,0 +1,98 @@
|
||||
task: detect
|
||||
mode: train
|
||||
model: yolov8n.pt
|
||||
data: datasets/faceData/data.yaml
|
||||
epochs: 300
|
||||
patience: 50
|
||||
batch: 4
|
||||
imgsz: 640
|
||||
save: true
|
||||
save_period: -1
|
||||
cache: true
|
||||
device: 0
|
||||
workers: 12
|
||||
project: null
|
||||
name: train
|
||||
exist_ok: false
|
||||
pretrained: true
|
||||
optimizer: auto
|
||||
verbose: true
|
||||
seed: 0
|
||||
deterministic: true
|
||||
single_cls: false
|
||||
rect: false
|
||||
cos_lr: false
|
||||
close_mosaic: 10
|
||||
resume: false
|
||||
amp: true
|
||||
fraction: 1.0
|
||||
profile: false
|
||||
freeze: null
|
||||
overlap_mask: true
|
||||
mask_ratio: 4
|
||||
dropout: 0.0
|
||||
val: true
|
||||
split: val
|
||||
save_json: false
|
||||
save_hybrid: false
|
||||
conf: null
|
||||
iou: 0.7
|
||||
max_det: 300
|
||||
half: false
|
||||
dnn: false
|
||||
plots: true
|
||||
source: null
|
||||
show: false
|
||||
save_txt: false
|
||||
save_conf: false
|
||||
save_crop: false
|
||||
show_labels: true
|
||||
show_conf: true
|
||||
vid_stride: 1
|
||||
stream_buffer: false
|
||||
line_width: null
|
||||
visualize: false
|
||||
augment: false
|
||||
agnostic_nms: false
|
||||
classes: null
|
||||
retina_masks: false
|
||||
boxes: true
|
||||
format: torchscript
|
||||
keras: false
|
||||
optimize: false
|
||||
int8: false
|
||||
dynamic: false
|
||||
simplify: false
|
||||
opset: null
|
||||
workspace: 4
|
||||
nms: false
|
||||
lr0: 0.01
|
||||
lrf: 0.01
|
||||
momentum: 0.937
|
||||
weight_decay: 0.0005
|
||||
warmup_epochs: 3.0
|
||||
warmup_momentum: 0.8
|
||||
warmup_bias_lr: 0.1
|
||||
box: 7.5
|
||||
cls: 0.5
|
||||
dfl: 1.5
|
||||
pose: 12.0
|
||||
kobj: 1.0
|
||||
label_smoothing: 0.0
|
||||
nbs: 64
|
||||
hsv_h: 0.015
|
||||
hsv_s: 0.7
|
||||
hsv_v: 0.4
|
||||
degrees: 0.0
|
||||
translate: 0.1
|
||||
scale: 0.5
|
||||
shear: 0.0
|
||||
perspective: 0.0
|
||||
flipud: 0.0
|
||||
fliplr: 0.5
|
||||
mosaic: 1.0
|
||||
mixup: 0.0
|
||||
copy_paste: 0.0
|
||||
cfg: null
|
||||
tracker: botsort.yaml
|
||||
save_dir: runs\detect\train
|
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 278 KiB |
After Width: | Height: | Size: 194 KiB |
After Width: | Height: | Size: 217 KiB |
After Width: | Height: | Size: 254 KiB |
After Width: | Height: | Size: 192 KiB |
After Width: | Height: | Size: 220 KiB |
After Width: | Height: | Size: 178 KiB |
After Width: | Height: | Size: 191 KiB |
After Width: | Height: | Size: 187 KiB |
After Width: | Height: | Size: 253 KiB |
After Width: | Height: | Size: 247 KiB |
After Width: | Height: | Size: 246 KiB |
After Width: | Height: | Size: 239 KiB |
@ -0,0 +1,105 @@
|
||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
# Settings
|
||||
FILE = Path(__file__).resolve()
|
||||
PARENT = FILE.parent # root directory
|
||||
README = (PARENT / 'README.md').read_text(encoding='utf-8')
|
||||
|
||||
|
||||
def get_version():
|
||||
"""
|
||||
Retrieve the version number from the 'ultralytics/__init__.py' file.
|
||||
|
||||
Returns:
|
||||
(str): The version number extracted from the '__version__' attribute in the 'ultralytics/__init__.py' file.
|
||||
"""
|
||||
file = PARENT / 'ultralytics/__init__.py'
|
||||
return re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', file.read_text(encoding='utf-8'), re.M)[1]
|
||||
|
||||
|
||||
def parse_requirements(file_path: Path):
|
||||
"""
|
||||
Parse a requirements.txt file, ignoring lines that start with '#' and any text after '#'.
|
||||
|
||||
Args:
|
||||
file_path (str | Path): Path to the requirements.txt file.
|
||||
|
||||
Returns:
|
||||
(List[str]): List of parsed requirements.
|
||||
"""
|
||||
|
||||
requirements = []
|
||||
for line in Path(file_path).read_text().splitlines():
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
requirements.append(line.split('#')[0].strip()) # ignore inline comments
|
||||
|
||||
return requirements
|
||||
|
||||
|
||||
setup(
|
||||
name='ultralytics', # name of pypi package
|
||||
version=get_version(), # version of pypi package
|
||||
python_requires='>=3.8',
|
||||
license='AGPL-3.0',
|
||||
description=('Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, '
|
||||
'pose estimation and image classification.'),
|
||||
long_description=README,
|
||||
long_description_content_type='text/markdown',
|
||||
url='https://github.com/ultralytics/ultralytics',
|
||||
project_urls={
|
||||
'Bug Reports': 'https://github.com/ultralytics/ultralytics/issues',
|
||||
'Funding': 'https://ultralytics.com',
|
||||
'Source': 'https://github.com/ultralytics/ultralytics'},
|
||||
author='Ultralytics',
|
||||
author_email='hello@ultralytics.com',
|
||||
packages=['ultralytics'] + [str(x) for x in Path('ultralytics').rglob('*/') if x.is_dir() and '__' not in str(x)],
|
||||
package_data={
|
||||
'': ['*.yaml'],
|
||||
'ultralytics.assets': ['*.jpg']},
|
||||
include_package_data=True,
|
||||
install_requires=parse_requirements(PARENT / 'requirements.txt'),
|
||||
extras_require={
|
||||
'dev': [
|
||||
'ipython',
|
||||
'check-manifest',
|
||||
'pre-commit',
|
||||
'pytest',
|
||||
'pytest-cov',
|
||||
'coverage',
|
||||
'mkdocs-material',
|
||||
'mkdocstrings[python]',
|
||||
'mkdocs-redirects', # for 301 redirects
|
||||
'mkdocs-ultralytics-plugin>=0.0.32', # for meta descriptions and images, dates and authors
|
||||
],
|
||||
'export': [
|
||||
'coremltools>=7.0',
|
||||
'openvino-dev>=2023.0',
|
||||
'tensorflow<=2.13.1',
|
||||
'tensorflowjs', # automatically installs tensorflow
|
||||
], },
|
||||
classifiers=[
|
||||
'Development Status :: 4 - Beta',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Education',
|
||||
'Intended Audience :: Science/Research',
|
||||
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Programming Language :: Python :: 3.10',
|
||||
'Programming Language :: Python :: 3.11',
|
||||
'Topic :: Software Development',
|
||||
'Topic :: Scientific/Engineering',
|
||||
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
||||
'Topic :: Scientific/Engineering :: Image Recognition',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Operating System :: MacOS',
|
||||
'Operating System :: Microsoft :: Windows', ],
|
||||
keywords='machine-learning, deep-learning, vision, ML, DL, AI, YOLO, YOLOv3, YOLOv5, YOLOv8, HUB, Ultralytics',
|
||||
entry_points={'console_scripts': ['yolo = ultralytics.cfg:entrypoint', 'ultralytics = ultralytics.cfg:entrypoint']})
|
@ -0,0 +1,15 @@
|
||||
#coding:utf-8
|
||||
from ultralytics import YOLO
|
||||
|
||||
# 加载模型
|
||||
model = YOLO("yolov8n.pt") # 加载预训练模型
|
||||
# Use the model
|
||||
if __name__ == '__main__':
|
||||
# Use the model
|
||||
results = model.train(data='datasets/faceData/data.yaml', epochs=300,device=0, batch=4,imgsz=640,cache=True,workers=12) # 训练模型
|
||||
# 将模型转为onnx格式
|
||||
# success = model.export(format='onnx')
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 88 KiB |