yolov3-ultralytics onnx

1. 下载工程文件 (yolov3-9.6.0)

① GitHub - ultralytics/yolov3: YOLOv3 in PyTorch > ONNX > CoreML > TFLite

git clone https://github.com/ultralytics/yolov3.git

② .pt文件 (链接: 百度网盘 请输入提取码 提取码: kclw)

https://github.com/ultralytics/yolov3/releases/download/v9.6.0/yolov3.pt

https://github.com/ultralytics/yolov3/releases/download/v9.6.0/yolov3-tiny.pt

③ coco文件(链接: 百度网盘 请输入提取码 提取码: gb49)

 https://ultralytics.com/assets/coco128.zip 

2. 创建环境

conda create -n yolov3-ult python=3.7 -y

3. 安装pytorch (要先看看requirements.txt中torch的版本要求)

conda activate yolov3-ult
conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=10.2 -c pytorch

4. 安装requirements.txt

pip install -r requirements.txt -i https://pypi.douban.com/simple --trusted-host pypi.douban.com

5. 训练

python train.py

yolov3-ultralytics onnx_第1张图片yolov3-ultralytics onnx_第2张图片yolov3-ultralytics onnx_第3张图片yolov3-ultralytics onnx_第4张图片yolov3-ultralytics onnx_第5张图片yolov3-ultralytics onnx_第6张图片

遇到的问题(GPU内存不足):

RuntimeError: CUDA out of memory. Tried to allocate 50.00 MiB (GPU 0; 5.93 GiB total capacity; 4.88 GiB already allocated; 13.75 MiB free; 4.93 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

感谢这位博主的解决: GPU内存不足解决方法

直接调整batch_size=4 (16 8 4 2) 从16逐渐调小

6. 测试

python detect.py --weights runs/train/exp/weights/best.pt

yolov3-ultralytics onnx_第7张图片

yolov3-ultralytics onnx_第8张图片yolov3-ultralytics onnx_第9张图片

 7. 可视化

tensorboard --logdir runs/train

yolov3-ultralytics onnx_第10张图片

8. 转onnx

pip install -U coremltools onnx scikit-learn==0.19.2

python export.py --weights yolov3.pt

yolov3-ultralytics onnx_第11张图片

yolov3-ultralytics onnx_第12张图片

 

 

 

你可能感兴趣的:(python,深度学习,深度学习,pytorch,python)