--- license: mit datasets: - ds4sd/DocLayNet language: - en metrics: - accuracy pipeline_tag: object-detection --- ## How to Get Started with the Model ### Install `ultralytics YOLO` package ``` shell $ pip install ultralytics ``` ### Perform Inference as per [kurkurzz](https://github.com/kurkurzz/custom-yolov8-auto-annotation-cvat-blueprint/blob/master/main.py) ``` python from ultralytics import YOLO from json import dumps checkpoint_path = "path/to/model/weight.pt" # e.g weights/best.pt in this directory model = YOLO(checkpoint_path) image_path = "path/to/image" infered = model(image_path) results = infered[0] boxes = result.boxes.data[:,:4] confs = result.boxes.conf clss = result.boxes.cls class_name = result.names #detected = results[0].boxes.xywh # or xywhn, xyxy pr xyxyn detections = [] threshold = 0.3 # 0 < threshold <= 1 for box, conf, cls in zip(boxes, confs, clss): label = class_name[int(cls)] if conf >= threshold: # must be in this format detections.append({ 'confidence': str(float(conf)), 'label': label, 'points': box.tolist(), 'type': 'rectangle', }) detected_objects = dumps(detections) print(detected_objects) ```