Views
No views yet
pip install yolov7detect1import yolov7
2
3# load pretrained or custom model
4model = yolov7.load('kadirnar/yolov7-tiny-v0.1', hf_model=True)
5
6# set model parameters
7model.conf = 0.25 # NMS confidence threshold
8model.iou = 0.45 # NMS IoU threshold
9model.classes = None # (optional list) filter by class
10
11# set image
12imgs = 'inference/images'
13
14# perform inference
15results = model(imgs)
16
17# inference with larger input size and test time augmentation
18results = model(img, size=1280, augment=True)
19
20# parse results
21predictions = results.pred[0]
22boxes = predictions[:, :4] # x1, y1, x2, y2
23scores = predictions[:, 4]
24categories = predictions[:, 5]
25
26# show detection bounding boxes on image
27results.show()@article{wang2022yolov7,
title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
journal={arXiv preprint arXiv:2207.02696},
year={2022}
}