2

我已经在 google colab 上使用 yoloV5 训练了我的模型,遵循提供的用于训练任何自定义模型的教程和演练:Colab file for training your own custom model。在运行提供的链接中的最后一个单元格后,我现在有一个导出的best.pt文件。现在,我想利用这个训练有素的权重在任何 python 脚本上本地运行检测。这可能吗?如果是这样,我该怎么做?

4

2 回答 2

1

You should follow this step:

  • Create an empty folder in desktop called ObjectDetection
  • Open command prompt and change directory to that new folder using cd ObjectDetection.
  • Clone yolov5 repo using command - git clone https://github.com/ultralytics/yolov5.git. It will create a new folder called yolov5 inside ObjectDetection folder.
    yolov5 folder contains important python file called detect.py which is responsible to detect the objects.
  • After cloning the repo, enter into yolov5 folder using cd yolov5
  • Install all the necessary requirements using - pip install -r requirements.txt
  • Download best.pt from colab and manually paste it inside yolov5 folder.
  • Also copy the image that you want to test inside yolov5 folder.
  • Before running inference, make sure that image.png, best.pt and detect.py should be in inside yolov5 folder.
  • You can then run inference inside yolov5 folder by using this command:
    python detect.py --weights best.pt --source image.png
  • After the process is completed, you can check the result inside path ObjectDetection/yolov5/runs/detect/exp
于 2021-06-09T04:27:58.877 回答
0

使用 colab 文件库

from google.colab import files
files.download('/content/yolov5/runs/train/yolov5s_results/weights/best.pt') 

如果路径不同,您可以更改路径。

于 2021-06-09T04:14:10.353 回答