yolov8学习笔记
1,将将.pt文件转化为.tiffle
absl-py 2.1.0
aiofiles 23.1.0
aiohttp 3.8.4
aiosignal 1.3.1
altair 5.0.1
anyio 3.7.0
argilla 1.9.0
arxiv 1.4.7
astor 0.8.1
astunparse 1.6.3
async-timeout 4.0.2
attrs 23.1.0
backoff 2.2.1
beautifulsoup4 4.12.2
boxmot 10.0.69
cachetools 5.3.1
certifi 2023.5.7
cffi 1.15.1
chardet 5.1.0
charset-normalizer 3.1.0
click 8.1.3
colorama 0.4.6
coloredlogs 15.0.1
commentjson 0.9.0
commonmark 0.9.1
contourpy 1.1.0
cryptography 41.0.1
cycler 0.11.0
dataclasses-json 0.5.8
decorator 5.1.1
deep-sort-realtime 1.3.2
deepsort 0.0.5
defusedxml 0.7.1
Deprecated 1.2.14
et-xmlfile 1.1.0
exceptiongroup 1.1.1
faiss-cpu 1.7.4
fastapi 0.97.0
feedparser 6.0.10
ffmpy 0.3.0
filelock 3.12.2
filetype 1.2.0
filterpy 1.4.5
fire 0.6.0
flatbuffers 1.12
fonttools 4.40.0
frozenlist 1.3.3
fsspec 2023.6.0
ftfy 6.2.0
gast 0.4.0
gdown 5.2.0
gitdb 4.0.11
GitPython 3.1.43
google-ai-generativelanguage 0.1.0
google-api-core 2.11.0
google-auth 2.20.0
google-auth-oauthlib 0.4.6
google-generativeai 0.1.0
google-pasta 0.2.0
google-search-results 2.4.2
googleapis-common-protos 1.59.1
googlesearch-python 1.2.3
gradio 3.30.0
gradio_client 0.2.4
greenlet 2.0.2
grpcio 1.66.1
grpcio-status 1.62.3
h11 0.14.0
h5py 3.11.0
httpcore 0.16.3
httpx 0.23.3
huggingface-hub 0.15.1
humanfriendly 10.0
idna 3.4
imageio 2.34.2
importlib_metadata 8.1.0
importlib-resources 5.12.0
intel-openmp 2021.4.0
jaraco.context 4.3.0
Jinja2 3.1.2
joblib 1.2.0
jsonschema 4.17.3
keras 2.9.0
keras-nightly 2.5.0.dev2021032900
Keras-Preprocessing 1.1.2
kiwisolver 1.4.4
langchain 0.0.173
lapx 0.5.9.post1
lark-parser 0.7.8
latex2mathml 3.76.0
libclang 18.1.1
linkify-it-py 2.0.2
loguru 0.7.2
lxml 4.9.2
Markdown 3.4.3
markdown-it-py 2.2.0
MarkupSafe 2.1.3
marshmallow 3.19.0
marshmallow-enum 1.5.1
matplotlib 3.9.2
mdit-py-plugins 0.3.3
mdtex2html 1.2.0
mdurl 0.1.2
mkl 2021.4.0
ml-dtypes 0.3.2
monotonic 1.6
more-itertools 9.1.0
mpmath 1.3.0
msg-parser 1.2.0
multidict 6.0.4
mypy-extensions 1.0.0
namex 0.0.8
networkx 3.2.1
nltk 3.8.1
numexpr 2.8.4
numpy 1.24.3
oauthlib 3.2.2
olefile 0.46
onnx 1.15.0
onnx-graphsurgeon 0.5.2
onnx-simplifier 0.4.33
onnx-tf 1.10.0
onnx2tf 1.7.7
onnxruntime 1.17.1
onnxruntime-gpu 1.14.1
onnxsim 0.4.28
onnxslim 0.1.31
openai 0.27.8
openapi-schema-pydantic 1.2.4
opencv-python 4.10.0.84
openpyxl 3.1.2
opt-einsum 3.3.0
optree 0.12.1
orjson 3.9.1
packaging 23.1
paddlepaddle-gpu 2.6.1
pandas 2.2.2
pandoc 2.3
pdf2image 1.16.3
pdfminer.six 20221105
pdfplumber 0.9.0
pillow 10.4.0
pip 23.1.2
plumbum 1.8.2
ply 3.11
proto-plus 1.22.2
protobuf 3.20.3
psutil 6.0.0
py-cpuinfo 9.0.0
pyasn1 0.5.0
pyasn1-modules 0.3.0
pybboxes 0.1.6
pybind11 2.13.5
pycparser 2.21
pydantic 1.10.9
pydub 0.25.1
Pygments 2.15.1
pypandoc 1.11
pyparsing 3.0.9
PyPDF2 3.0.1
pypinyin 0.49.0
pyreadline3 3.4.1
pyrsistent 0.19.3
PySocks 1.7.1
python-dateutil 2.8.2
python-docx 0.8.11
python-magic 0.4.27
python-multipart 0.0.6
python-pptx 0.6.21
pytz 2023.3
pywin32 306
PyYAML 6.0.1
regex 2024.5.15
requests 2.31.0
requests-oauthlib 2.0.0
rfc3986 1.5.0
rich 13.0.1
rsa 4.9
sahi 0.11.18
scikit-learn 1.5.1
scipy 1.9.3
seaborn 0.13.2
semantic-version 2.10.0
setuptools 74.0.0
sgmllib3k 1.0.0
shapely 2.0.5
six 1.15.0
smmap 5.0.1
sng4onnx 1.0.1
sniffio 1.3.0
socksio 1.0.0
sounddevice 0.5.0
soupsieve 2.4.1
SQLAlchemy 2.0.16
starlette 0.27.0
supervision 0.22.0
sympy 1.12.1
tabulate 0.9.0
tbb 2021.13.0
tenacity 8.2.2
tensorboard 2.9.1
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.9.3
tensorflow-estimator 2.9.0
tensorflow-gpu 2.9.1
tensorflow-io-gcs-filesystem 0.31.0
termcolor 2.4.0
tflite-support 0.3.1
thop 0.1.1.post2209072238
threadpoolctl 3.5.0
tiktoken 0.4.0
toolz 0.12.0
torch 1.9.1+cu102
torchaudio 0.9.1
torchvision 0.10.1+cu102
tqdm 4.65.0
typeguard 2.13.3
typer 0.9.0
typing_extensions 4.5.0
typing-inspect 0.9.0
tzdata 2024.1
uc-micro-py 1.0.2
ultralytics 8.0.140
unstructured 0.7.5
urllib3 1.26.16
uvicorn 0.22.0
Wand 0.6.11
wcwidth 0.2.13
websockets 11.0.3
Werkzeug 3.0.4
wheel 0.44.0
wikipedia 1.4.0
win32-setctime 1.1.0
wolframalpha 5.0.0
wrapt 1.12.1
xlrd 2.0.1
XlsxWriter 3.1.2
xmltodict 0.13.0
yacs 0.1.8
yarl 1.9.2
zipp 3.15.0
注意:
必须先确保tensorflow、onnx2tf、onnx安装正确。用import tensorflow /onnx2tf/onnx确定是否正确安装。下面是验证正确的版本号
ultralytics 8.0.140
tensorflow-gpu 2.9.1onnx',
'onnx2tf>=1.7.7',
'sng4onnx>=1.0.1',
'onnxsim>=0.4.17',
'onnx_graphsurgeon>=0.3.26',
'tflite_support',
'onnxruntime-gpu
错误1:AttributeError: FLOAT8E4M3FN
这个是onnx的版本有问题,change onnx version from 1.12.0 to 1.16.1 or 1.15.1,it will works!。
更新:下面是训练的版本号
$ pip3.9 list
Package Version
---------------------------- ------------
absl-py 2.1.0
anyio 4.4.0
astor 0.8.1
astunparse 1.6.3
cachetools 5.5.0
certifi 2024.8.30
charset-normalizer 3.3.2
colorama 0.4.6
coloredlogs 15.0.1
contourpy 1.3.0
cycler 0.12.1
decorator 5.1.1
exceptiongroup 1.2.2
flatbuffers 1.12
fonttools 4.53.1
gast 0.4.0
google-auth 2.34.0
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
grpcio 1.66.1
h11 0.14.0
h5py 3.11.0
httpcore 1.0.5
httpx 0.27.2
humanfriendly 10.0
idna 3.8
importlib-metadata 8.5.0
keras 2.9.0
Keras-Preprocessing 1.1.2
kiwisolver 1.4.7
libclang 18.1.1
Markdown 3.7
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.6.0
mdurl 0.1.2
mpmath 1.3.0
numpy 1.24.3
oauthlib 3.2.2
onnx 1.14.0
onnx-graphsurgeon 0.5.2
onnx2tf 1.7.7
onnxruntime 1.17.1
onnxsim 0.4.28
opencv-python 4.10.0.84
opt-einsum 3.3.0
packaging 24.1
paddlelite 2.13rc0
paddlepaddle 2.6.1
paddlepaddle-gpu 2.6.1
pandas 2.2.2
Pillow 8.3.2
pip 20.2.1
protobuf 3.20.0
psutil 6.0.0
py-cpuinfo 9.0.0
pyasn1 0.6.1
pyasn1-modules 0.4.1
pybind11 2.13.5
pygments 2.18.0
pyparsing 3.1.4
pyreadline3 3.4.3
python-dateutil 2.9.0.post0
pytz 2024.2
PyYAML 6.0.2
requests 2.32.3
requests-oauthlib 2.0.0
rich 13.8.1
rsa 4.9
scipy 1.13.1
seaborn 0.13.2
setuptools 49.2.1
six 1.16.0
sng4onnx 1.0.1
sniffio 1.3.1
sympy 1.13.2
tensorboard 2.9.1
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow 2.9.1
tensorflow-estimator 2.9.0
tensorflow-io-gcs-filesystem 0.31.0
termcolor 2.4.0
tflite-support 0.3.1
torch 1.9.1+cu102
torchaudio 0.9.1
torchvision 0.10.1+cu102
tqdm 4.66.5
typing-extensions 4.12.2
tzdata 2024.1
ultralytics 8.0.140
urllib3 2.2.2
werkzeug 3.0.4
wheel 0.44.0
wrapt 1.16.0
zipp 3.20.1
WARNING: You are using pip version 20.2.1; however, version 24.2 is available.
You should consider upgrading via the 'e:\work\py39\python_39.exe -m pip install --upgrade pip' command.
更新,报错1 :
Exception ignored in atexit callback: <function enablerlcompleter.<locals>.register_readline.<locals>.write_history at 0x000001A3B8B13E20>
Traceback (most recent call last):File "E:\work\py310\lib\site.py", line 483, in write_historyreadline.write_history_file(history)File "E:\work\py310\lib\site-packages\pyreadline3\rlmain.py", line 183, in write_history_fileself.mode._history.write_history_file(filename)File "E:\work\py310\lib\site-packages\pyreadline3\lineeditor\history.py", line 105, in write_history_filefp.writeln(line.get_line_text())
AttributeError: '_io.TextIOWrapper' object has no attribute 'writeln'
修改:
for line in self.history[-self.history_length:]:# fp.writeln(line.get_line_text())fp.write(line.get_line_text())
更新:用python3.10将.pt模型转为.tftile格式模型。
python3.10, tensorflow==2.17.0,onnx==1.16.0, ultralytics==8.0.140.
$ pip3.10 list
WARNING: Ignoring invalid distribution -rotobuf (e:\work\py310\lib\site-packages)
Package Version
---------------------------- ------------
absl-py 2.1.0
astunparse 1.6.3
cachetools 5.5.0
certifi 2024.8.30
charset-normalizer 3.3.2
colorama 0.4.6
coloredlogs 15.0.1
contourpy 1.3.0
cycler 0.12.1
defusedxml 0.7.1
flatbuffers 24.3.25
fonttools 4.53.1
gast 0.4.0
google-auth 2.34.0
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
grpcio 1.66.1
h5py 3.11.0
humanfriendly 10.0
idna 3.8
keras 3.5.0
Keras-Preprocessing 1.1.2
kiwisolver 1.4.7
libclang 18.1.1
Markdown 3.7
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.9.2
mdurl 0.1.2
ml-dtypes 0.4.0
mpmath 1.3.0
namex 0.0.8
networkx 3.1
numpy 1.26.4
oauthlib 3.2.2
onnx 1.16.0
onnx-graphsurgeon 0.5.2
onnx2tf 1.22.3
onnxruntime 1.19.2
onnxruntime-gpu 1.19.2
onnxsim 0.4.36
onnxslim 0.1.32
opencv-python 4.10.0.84
openvino 2024.3.0
openvino-dev 2024.3.0
openvino-telemetry 2024.1.0
opt-einsum 3.3.0
optree 0.12.1
packaging 24.1
pandas 2.2.2
pillow 10.4.0
pip 23.0.1
protobuf 4.25.4
psutil 6.0.0
py-cpuinfo 9.0.0
pyasn1 0.6.1
pyasn1_modules 0.4.1
pybind11 2.13.5
Pygments 2.18.0
pyparsing 3.1.4
pyreadline3 3.4.3
python-dateutil 2.9.0.post0
pytz 2024.2
PyYAML 6.0.2
requests 2.32.3
requests-oauthlib 2.0.0
rich 13.8.1
rsa 4.9
scipy 1.14.1
seaborn 0.13.2
setuptools 65.5.0
six 1.16.0
sng4onnx 1.0.4
sympy 1.13.2
tensorboard 2.17.1
tensorboard-data-server 0.7.2
tensorflow 2.17.0
tensorflow-intel 2.17.0
tensorflow-io-gcs-filesystem 0.31.0
termcolor 2.4.0
tf_keras 2.17.0
tflite-support 0.1.0a1
torch 1.12.1+cu113
torchaudio 0.12.1
torchvision 0.13.1+cu113
tqdm 4.66.5
typing_extensions 4.12.2
tzdata 2024.1
ultralytics 8.2.91
ultralytics-thop 2.0.6
urllib3 2.2.3
Werkzeug 3.0.4
wheel 0.44.0
wrapt 1.16.0
WARNING: Ignoring invalid distribution -rotobuf (e:\work\py310\lib\site-packages)
WARNING: Ignoring invalid distribution -rotobuf (e:\work\py310\lib\site-packages)
WARNING: Ignoring invalid distribution -rotobuf (e:\work\py310\lib\site-packages)[notice] A new release of pip is available: 23.0.1 -> 24.2
[notice] To update, run: python_310.exe -m pip install --upgrade pipHX@DESKTOP-LTLB65A MINGW64 /e
按照以上配置转换成功示例如下:
from ultralytics import YOLO# Load the YOLOv8 model
model = YOLO("yolov8n.pt")# Export the model to TFLite format
model.export(format="tflite") # creates 'yolov8n_float32.tflite'# Load the exported TFLite model
tflite_model = YOLO("yolov8n_float32.tflite")# Run inference
results = tflite_model("https://ultralytics.com/images/bus.jpg")
from ultralytics import YOLO
# from tensorflow.python.framework.ops import disable_eager_execution# model = YOLO('yolov8m.pt') # 这里 'yolov8s.pt' 是模型权重文件
model = YOLO('yolov8m-pose.pt') # 这里 'yolov8s.pt' 是模型权重文件
model.export(format="tflite")
# model.export(format="tflite", data='coco.yaml')
# model.export(format="onnx")
# yolo export model=yolov8n.pt format=onnx imgsz=288,512
# onnx2tf -i yolov8n.onnx -o yolov8n_float32.tflite -b 1
yolo predict task=pose model=yolov8m-pose_saved_model\yolov8m-pose_float32.tflite imgsz=640