1.参考:https://blog.csdn.net/WhiffeYF/article/details/127583796?spm=1001.2014.3001.5502
2.下载解压后,anaconda创建新环境yolov7w,pycharm界面settings里选择yolov7w,run里面环境变量也换成 yolov7w。
3.下载权重文件yolov7x.pt:https://share.weiyun.com/wreukCC0,放到根目录下,名字改成跟程序里一样的yolov7.pt
4、安装依赖requirements.txt
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
!!!!!!!这里发生了错误
RuntimeError: Couldn't load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions
我的cuda=11.3,pyhon版本3.7,按官网的安装1.12的报上面的错误,改成1.11的可以了
![失败](https://i-blog.csdnimg.cn/blog_migrate/b84532323ef1c2bacc74e2d6f5c9e19b.png)
![成功的](https://i-blog.csdnimg.cn/blog_migrate/209165205ad96fa7c89519eae84c0a69.png)
5.运行detect.py
python detect.py --weights yolov7x.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg
结果: