Closed lyylsh closed 1 year ago
hahah,me too
hahah,me too
I found that the drop in accuracy was due to the fact that the image scaling process used was not proportional scaling, which is used in the yolo source code.
@ibaiGorordo for anybody wondering how to add padding: https://gist.github.com/IdeaKing/11cf5e146d23c5bb219ba3508cca89ec
Example usage code:
class_names = {0: 'a', 1: 'b', 2: 'c'}
yolov8_detector = YOLOv8("yolov8_custom_trained_model.onnx", conf_thres=0.01, iou_thres=0.01)
def detect(img_url):
class_names = {0: 'adult', 1: 'nipple', 2: 'underage'}
img = imread_from_url(img_url)
img = resize_with_pad(img, (800, 800))
_, scores, class_ids = yolov8_detector(img)
prediction = map(
lambda x: [class_names[x[0]], float(x[1])], zip(class_ids, scores)
)
return list(prediction)
great, thanks
This will fix the problem with lower scores. However, it will mess up the position of the bounding box on the smaller side axis. So there also needs to be some logic to recaculate the BBs without the padding.
When I converted the yolov8n model to onnx, the accuracy of the model dropped a lot. What should I do?Thanks