0
点赞
收藏
分享

微信扫一扫

Windows10 yolox 安装


yolox 安装

环境

  • Windows:10
  • Anaconda:2.0.4
  • Python 3.7.10
  • torch:1.7.0
  • torchvision:0.8.0
  • YOLOX:0.1.0

yolox官网:​​https://github.com/Megvii-BaseDetection/YOLOX​​

使用 conda 创建环境

conda create -n yolox ;python=3.7

激活环境

conda activate yolox

(base) C:\Users\vvcat>conda activate yolox
(yolox) C:\Users\vvcat>

下载pytorch

conda install ;pytorch==1.7.0 ;torchvision==0.8.0 ;torchaudio==0.7.0 ;cudatoolkit=10.1 -c pytorch

测试pytorch GPU版是否安装成功

python

import torch
print(torch.cuda.is_available())

(yolox) C:\Users\vvcat>python
Python 3.7.10 | packaged by conda-forge | (default, Feb 19 2021, 15:37:01) [MSC v.1916 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True

cd C:\Users\vvcat\Desktop\YOLOX-0.1.0

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>dir
驱动器 C 中的卷是 系统
卷的序列号是 0007-1737
C:\Users\vvcat\Desktop\YOLOX-0.1.0 的目录
2021/09/05 12:36 <DIR> .
2021/09/05 12:36 <DIR> …
2021/09/04 10:37 <DIR> .github
2021/09/04 10:37 3,098 .gitignore
2021/09/04 10:37 537 .readthedocs.yaml
2021/09/04 10:37 <DIR> assets
2021/09/04 10:37 <DIR> datasets
2021/09/04 10:37 <DIR> demo
2021/09/04 10:37 <DIR> docs
2021/09/04 10:37 <DIR> exps
2021/09/04 10:37 11,352 LICENSE
2021/09/04 10:37 10,495 README.md
2021/09/04 10:37 222 requirements.txt
2021/09/04 10:37 615 setup.cfg
2021/09/04 10:37 1,678 setup.py
2021/09/04 10:37 <DIR> tools
2021/09/04 10:37 <DIR> yolox
7 个文件 27,997 字节
10 个目录 11,595,075,584 可用字节

安装yolox需要的依赖包

pip install -r requirements.txt

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>pip install -r requirements.txt
Requirement already satisfied: numpy in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from -r requirements.txt (line 2)) (1.21.2)
Requirement already satisfied: torch>=1.7 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from -r requirements.txt (line 3)) (1.7.0)



c:\users\vvcat\appdata\local\pip\cache\wheels\8a\b4\1b\6acdd4eb854b215cd4aa1c18ca79399f9d34728edaff47ecce
Successfully built onnx-simplifier
Installing collected packages: urllib3, six, pyasn1, idna, charset-normalizer, certifi, zipp, rsa, requests, pyasn1-modules, protobuf, oauthlib, cachetools, requests-oauthlib, python-dateutil, pyparsing, onnx, kiwisolver, importlib-metadata, google-auth, future, flatbuffers, dataclasses, cycler, win32-setctime, werkzeug, tifffile, tensorboard-plugin-wit, tensorboard-data-server, scipy, PyWavelets, onnxruntime, onnxoptimizer, networkx, matplotlib, markdown, imageio, grpcio, google-auth-oauthlib, colorama, absl-py, tqdm, thop, tensorboard, tabulate, scikit-image, opencv-python, onnx-simplifier, ninja, loguru
Successfully installed PyWavelets-1.1.1 absl-py-0.13.0 cachetools-4.2.2 certifi-2021.5.30 charset-normalizer-2.0.4 colorama-0.4.4 cycler-0.10.0 dataclasses-0.6 flatbuffers-2.0 future-0.18.2 google-auth-1.35.0 google-auth-oauthlib-0.4.6 grpcio-1.39.0 idna-3.2 imageio-2.9.0 importlib-metadata-4.8.1 kiwisolver-1.3.2 loguru-0.5.3 markdown-3.3.4 matplotlib-3.4.3 networkx-2.6.2 ninja-1.10.2 oauthlib-3.1.1 onnx-1.8.1 onnx-simplifier-0.3.5 onnxoptimizer-0.2.6 onnxruntime-1.8.0 opencv-python-4.5.3.56 protobuf-3.17.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 pyparsing-2.4.7 python-dateutil-2.8.2 requests-2.26.0 requests-oauthlib-1.3.0 rsa-4.7.2 scikit-image-0.18.3 scipy-1.7.1 six-1.16.0 tabulate-0.8.9 tensorboard-2.6.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.0 thop-0.0.31.post2005241907 tifffile-2021.8.30 tqdm-4.62.2 urllib3-1.26.6 werkzeug-2.0.1 win32-setctime-1.0.3 zipp-3.5.0

安装yolox:

python setup.py install

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>python setup.py install
running install
running bdist_egg
running egg_info
creating yolox.egg-info
writing yolox.egg-info\PKG-INFO
writing dependency_links to yolox.egg-info\dependency_links.txt
writing top-level names to yolox.egg-info\top_level.txt
writing manifest file ‘yolox.egg-info\SOURCES.txt’
reading manifest file ‘yolox.egg-info\SOURCES.txt’
adding license file ‘LICENSE’
writing manifest file ‘yolox.egg-info\SOURCES.txt’
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib.win-amd64-3.7



Installed h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages\yolox-0.1.0-py3.7-win-amd64.egg
Processing dependencies for yolox==0.1.0
Finished processing dependencies for yolox==0.1.0

apex:​​https://github.com/NVIDIA/apex​​ 下载apex,解压到yolox项目文件夹内

Windows10 yolox 安装_pytorch
cd到apex文件夹内

cd apex-master

安装 apex

python setup.py install

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0\apex-master>python setup.py install
torch.__version__ = 1.7.0
setup.py:67: UserWarning: Option --pyprof not specified. Not installing PyProf dependencies!
warnings.warn(“Option --pyprof not specified. Not installing PyProf dependencies!”)
running install
running bdist_egg
running egg_info
creating apex.egg-info
writing apex.egg-info\PKG-INFO
writing dependency_links to apex.egg-info\dependency_links.txt
writing top-level names to apex.egg-info\top_level.txt
writing manifest file ‘apex.egg-info\SOURCES.txt’
reading manifest file ‘apex.egg-info\SOURCES.txt’
adding license file ‘LICENSE’
writing manifest file ‘apex.egg-info\SOURCES.txt’
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build



Installed h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages\apex-0.1-py3.7.egg
Processing dependencies for apex==0.1
Finished processing dependencies for apex==0.1

安装 pycocotools

pip install pycocotools

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0\apex-master>pip install pycocotools
Collecting pycocotools
Using cached pycocotools-2.0.2-cp37-cp37m-win_amd64.whl
Collecting cython>=0.27.3
Using cached Cython-0.29.24-cp37-cp37m-win_amd64.whl (1.6 MB)
Requirement already satisfied: matplotlib>=2.1.0 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from pycocotools) (3.4.3)
Requirement already satisfied: setuptools>=18.0 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from pycocotools) (57.4.0)
Requirement already satisfied: pillow>=6.2.0 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (8.3.2)
Requirement already satisfied: python-dateutil>=2.7 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.8.2)
Requirement already satisfied: pyparsing>=2.2.1 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (2.4.7)
Requirement already satisfied: cycler>=0.10 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.3.2)
Requirement already satisfied: numpy>=1.16 in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from matplotlib>=2.1.0->pycocotools) (1.21.2)
Requirement already satisfied: six in h:\anacondanavigator\anaconda\envs\yolox\lib\site-packages (from cycler>=0.10->matplotlib>=2.1.0->pycocotools) (1.16.0)
Installing collected packages: cython, pycocotools
Successfully installed cython-0.29.24 pycocotools-2.0.2

下载预训练模型:
yolox_s.pth:
​​​https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s.pth​​

将下载的预训练模型放在 yolox 目录下
Windows10 yolox 安装_desktop_02

测试效果

cd C:\Users\vvcat\Desktop\YOLOX-0.1.0

python tools/demo.py image -f exps/default/yolox_s.py -c ./yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>python tools/demo.py image -f exps/default/yolox_s.py -c ./yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu
2021-09-05 16:27:33.304 | INFO | main:main:239 - Args: Namespace(camid=0, ckpt=’./yolox_s.pth’, conf=0.25, demo=‘image’, device=‘cpu’, exp_file=‘exps/default/yolox_s.py’, experiment_name=‘yolox_s’, fp16=False, fuse=False, name=None, nms=0.45, path=‘assets/dog.jpg’, save_result=True, trt=False, tsize=640)
2021-09-05 16:27:33.576 | INFO | main:main:249 - Model Summary: Params: 8.97M, Gflops: 26.81
2021-09-05 16:27:33.580 | INFO | main:main:260 - loading checkpoint
2021-09-05 16:27:33.724 | INFO | main:main:264 - loaded checkpoint done.
2021-09-05 16:27:34.355 | INFO | main:inference:150 - Infer time: 0.5810s
2021-09-05 16:27:34.361 | INFO | main:image_demo:187 - Saving detection result in ./YOLOX_outputs\yolox_s\vis_res\2021_09_05_16_27_33\dog.jpg

图片输出路径为

Windows10 yolox 安装_pytorch_03

./YOLOX_outputs\yolox_s\vis_res\2021_09_05_16_27_33

得到的测试结果:

Windows10 yolox 安装_pytorch_04

测试 轻型模型:YOLOX-Nano

​​https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_nano.pth​​

python tools/demo.py image -f exps/default/nano.py.py -c ./yolox_nano.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>python tools/demo.py image -f exps/default/nano.py.py -c ./yolox_nano.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu
2021-09-05 18:03:14.509 | INFO | main:main:239 - Args: Namespace(camid=0, ckpt=’./yolox_nano.pth’, conf=0.25, demo=‘image’, device=‘cpu’, exp_file=‘exps/default/nano.py.py’, experiment_name=‘nano’, fp16=False, fuse=False, name=None, nms=0.45, path=‘assets/dog.jpg’, save_result=True, trt=False, tsize=640)
2021-09-05 18:03:14.737 | INFO | main:main:249 - Model Summary: Params: 0.91M, Gflops: 2.55
2021-09-05 18:03:14.742 | INFO | main:main:260 - loading checkpoint
2021-09-05 18:03:14.915 | INFO | main:main:264 - loaded checkpoint done.
2021-09-05 18:03:15.266 | INFO | main:inference:150 - Infer time: 0.2907s
2021-09-05 18:03:15.271 | INFO | main:image_demo:187 - Saving detection result in ./YOLOX_outputs\nano\vis_res\2021_09_05_18_03_14\dog.jpg

测试结果:
Windows10 yolox 安装_desktop_05

遇到以下问题 No module named ‘yolox’

(yolox) C:\Users\vvcat\Desktop\YOLOX-0.1.0>python tools/demo.py image -f exps/default/yolox_s.py -c ./yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device cpu
Traceback (most recent call last):
File “tools/demo.py”, line 14, in <module>
from yolox.data.data_augment import preproc
ModuleNotFoundError: No module named ‘yolox’

解决方法:
安装yolox:

Windows10 yolox 安装_python_06

python setup.py install

举报

相关推荐

0 条评论