LoginSignup
0
0

YOLOv7におけるバウンディングボックスの太さ変更

Last updated at Posted at 2023-12-01

YOLOv7におけるバウンディングボックスの太さ変更の方法をメモしておきます。

Google Colaboratoryにて実行しました。
ランタイム->ランタイムのタイプを変更->T4 GPUを選択

from google.colab import drive
drive.mount('/content/drive')
%cd "/content/drive/MyDrive"
!git clone https://github.com/WongKinYiu/yolov7
%cd "/content/drive/MyDrive/yolov7"
!pip install -r requirements.txt

物体検出(結果はyolov7/runs/detectに保存される)

%cd "/content/drive/MyDrive/yolov7"
!python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source "/content/drive/MyDrive/yolov7/inference/images/horses.jpg"

horses.jpg

この画像が出力されます。
バウンディングボックスの太さ変更のため、detect.pyの129行目を以下のように書き換えます。

detect.py
# 129行目
plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=2) # line_thickness=1をline_thickness=2に変更

以下のコードをGoogle Colaboratoryにて再度実行します。

%cd "/content/drive/MyDrive/yolov7"
!python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source "/content/drive/MyDrive/yolov7/inference/images/horses.jpg"

horses.jpg

バウンディングボックスが太くなりました。
YOLOv7にはバウンディングボックスの太さに関するオプションがなかったため、detect.pyを書き換えることでバウンディングボックスの太さ変更を行いました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0