Views
No views yet
pip install -U yolov81import yolov5
2# load model
3model = yolov5.load('fcakyon/yolov5n-v7.0')
4
5# set model parameters
6model.conf = 0.25 # NMS confidence threshold
7model.iou = 0.45 # NMS IoU threshold
8model.agnostic = False # NMS class-agnostic
9model.multi_label = False # NMS multiple labels per box
10model.max_det = 1000 # maximum number of detections per image
11# set image
12img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
13# perform inference
14results = model(img)
15# inference with larger input size
16results = model(img, size=640)
17# inference with test time augmentation
18results = model(img, augment=True)
19# parse results
20predictions = results.pred[0]
21boxes = predictions[:, :4] # x1, y1, x2, y2
22scores = predictions[:, 4]
23categories = predictions[:, 5]
24# show detection bounding boxes on image
25results.show()
26# save results into "results/" folder
27results.save(save_dir='results/')yolov5 train --img 640 --batch 16 --weights fcakyon/yolov5n-v7.0 --epochs 10 --device cuda:0