opencvとPytorchを組み合わせたときのバグ
なぜか、25個以上のバウンディングボックスを表示できない
import torch
import cv2
import numpy as np
#定数
IMAGE_PATH = '/home/snowyowl/Downloads/yolov5-master/data/images/252532.jpg'
#yolov5を動かす
model = torch.hub.load('/home/snowyowl/Downloads/yolov5-master', 'custom', path='/home/snowyowl/Downloads/yolov5-master/yolov5s.pt', source='local')
img = cv2.imread(IMAGE_PATH)
results = model(img)
results.display(pprint=True)
image 1/1 /home/snowyowl/Downloads/yolov5-master/data/images/classroom.jpg: 480x640 33 desks, Done. (0.070s)
↑yolov5で直接実行
image 1/1: 3024x4032 25 desks
↑
25で止まってる。Qなんで?
A
import torch
import cv2
import numpy as np
#定数
IMAGE_PATH = '/home/snowyowl/Downloads/yolov5-master/data/images/classroom.jpg'
#yolov5を動かす runs/train/exp80/weights/best.pt
model = torch.hub.load('/home/snowyowl/Downloads/yolov5-master', 'custom', path='/home/snowyowl/Downloads/yolov5-master/yolov5s.pt', source='local')
results = model(IMAGE_PATH)
results.display(pprint=True)
results.show()
多分opencvの方の問題
results = model(IMAGE_PATH)
modelの引数を直接IMAGE_PATHにしたら、直った