Views
No views yet
pip install -r requirements.txt 1└── datasets
2 └── coco
3 ├── annotations
4 | ├── instances_val2017.json
5 | └── ...
6 ├── labels
7 | ├── val2017
8 | | ├── 000000000139.txt
9 | ├── 000000000285.txt
10 | └── ...
11 ├── images
12 | ├── val2017
13 | | ├── 000000000139.jpg
14 | ├── 000000000285.jpg
15 └── val2017.txt1path: /path/to/your/datasets/coco # dataset root dir
2train: train2017.txt # train images (relative to 'path') 118287 images
3val: val2017.txt # val images (relative to 'path') 5000 imagesinfer_onnx.py on how to use1 args = make_parser().parse_args()
2 onnx_path = args.onnx_model
3 onnx_weight = onnxruntime.InferenceSession(onnx_path)
4 grid = np.load("./grid.npy", allow_pickle=True)
5 anchor_grid = np.load("./anchor_grid.npy", allow_pickle=True)
6 path = args.image_path
7 new_path = args.output_path
8 conf_thres, iou_thres, classes, agnostic_nms, max_det = 0.25, 0.45, None, False, 1000
9
10 img0 = cv2.imread(path)
11 img = pre_process(img0)
12 onnx_input = {onnx_weight.get_inputs()[0].name: img}
13 onnx_output = onnx_weight.run(None, onnx_input)
14 onnx_output = post_process(onnx_output)
15 pred = non_max_suppression(
16 onnx_output[0], conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det
17 )
18 colors = Colors()
19 det = pred[0]
20 im0 = img0.copy()
21 annotator = Annotator(im0, line_width=2, example=str(names))
22 if len(det):
23 # Rescale boxes from img_size to im0 size
24 det[:, :4] = scale_coords(img.shape[2:], det[:, :4], im0.shape).round()
25
26 # Write results
27 for *xyxy, conf, cls in reversed(det):
28 c = int(cls) # integer class
29 label = f"{names[c]} {conf:.2f}"
30 annotator.box_label(xyxy, label, color=colors(c, True))
31 # Stream results
32 im0 = annotator.result()
33 cv2.imwrite(new_path, im0)python infer_onnx.py --onnx_model ./yolov5s.onnx -i /Path/To/Your/Image --ipu --provider_config /Path/To/Your/Provider_configpython eval_onnx.py --onnx_model ./yolov5s.onnx --ipu --provider_config /Path/To/Your/Provider_config| Metric | Accuracy on IPU |
|---|---|
| AP@0.50:0.95 | 0.356 |
1@software{glenn_jocher_2021_5563715,
2 author = {Glenn Jocher et. al.},
3 title = {{ultralytics/yolov5: v6.0 - YOLOv5n 'Nano' models,
4 Roboflow integration, TensorFlow export, OpenCV
5 DNN support}},
6 month = oct,
7 year = 2021,
8 publisher = {Zenodo},
9 version = {v6.0},
10 doi = {10.5281/zenodo.5563715},
11 url = {https://doi.org/10.5281/zenodo.5563715}
12}