ubuntu 18.04
****************************************************************************
https://github.com/WongKinYiu/yolor
1. Create a virtual environment to hold OpenCV 4.5, yolov4 and additional
packages
mkvirtualenv myrgpu -p python3
workon yolorgpu
pip install numpy
pip install opencv-contrib-python
git clone https://github.com/WongKinYiu/yolor (main)
cd yolor
# pip install required packages
pip install -r requirements.txt
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0
-f https://download.pytorch.org/whl/torch_stable.html
pip install -U cython
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
(myrgpu) ubuntu@server:/data/Taiwan/yolorProjects$ python
Python 3.6.9 (default, Dec 8 2021, 21:08:43)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or
"license" for more information.
>>> import torch
>>> torch.__version__
'1.9.0+cu111'
>>> torch.cuda.is_available()
True
>>> quit()
# install mish-cuda if you want to use mish activation
# https://github.com/thomasbrandon/mish-cuda
# https://github.com/JunnYu/mish-cuda
git clone https://github.com/JunnYu/mish-cuda
cd mish-cuda
python setup.py build install
cd ..
# install pytorch_wavelets if you want to use dwt down-sampling module
# https://github.com/fbcotter/pytorch_wavelets
git clone https://github.com/fbcotter/pytorch_wavelets
cd pytorch_wavelets
pip install .
cd ..
Inference
(myrgpu) ubuntu@server:/data/Taiwan/yolorProjects/yolor$
python detect.py --source inference/images/horses.jpg --cfg cfg/yolor_p6.cfg
--weights yolor_p6.pt --conf 0.25 --img-size 1280
--device 0
(myrgpu) ubuntu@server:/data/Taiwan/yolorProjects/yolor$
python detect.py --source
/data/Taiwan/coco/C417/111/2021_12_07_16_24_36_844346.jpg --cfg
cfg/yolor_p6.cfg --weights yolor_p6.pt --conf 0.25 --img-size 1280
--device 0
******************************************************************
💚Train💚 :
python -m torch.distributed.launch --nproc_per_node 2 --master_port 9527
train.py --batch-size 8 --img 1280 1280 --data car81.yaml --cfg
cfg/yolor_p6.cfg --weights '' --device 1,2 --sync-bn --name gogogo1 --hyp
hyp.scratch.1280.yaml --epochs 800
💚Detect💚 :
python detect.py --source data/car_test/images/test0.jpg --names data/car.names --cfg cfg/yolor_p6.cfg --weights runs/train/fight1/weights/best.pt --conf 0.25 --img-size 1280 --device 0
#add output #conf 0.25
python detect.py --source data/car_test/images/ --names data/car81.names --cfg cfg/yolor_p6_car81.cfg --weights runs/train/go81_2/weights/best.pt --output inference/output_go81_2 --conf 0.25 --img-size 1280 --device 0
#change conf as 0.5 #change output address
python detect.py --source data/car_test/images/ --names data/car81.names
--cfg cfg/yolor_p6_car81.cfg --weights runs/train/go81_2/weights/best.pt
--output inference/output_go81_3 --conf 0.5 --img-size 1280 --device 0
#change conf as 0.4 #change output address
python detect.py --source data/car_test/images/ --names data/car81.names
--cfg cfg/yolor_p6_car81.cfg --weights runs/train/go81_2/weights/best.pt
--output inference/output_go81_4 --conf 0.4 --img-size 1280 --device 0
在detect的時候, 指令裡面一定要加--names,
因為YoloR names的default是coco.names,
所以若你偵測的時候沒有加上names,
跑出來的結果就會變成apple, person之類的, 這點請務必注意唷
另外在detect的時候, --device 只可以是0,
若改成1, 2…就會跑不動,
參數--conf 0.25表示什麼意思?
意思是置信度低於0.25的框不要顯示出來~
沒有留言:
張貼留言
喜歡我的文章嗎? 喜歡的話可以留言回應我喔! ^^