Hi @NotGrant,
Could you please try running the following script?
import argparse
import cv2
from depthai_sdk import OakCamera, ArgsParser
from depthai_sdk.classes import DetectionPacket
from depthai_sdk.visualize.configs import TextPosition
parser = argparse.ArgumentParser()
parser.add_argument("-conf", "--config", help="Trained YOLO json config path", default='json/best.json', type=str)
args = ArgsParser.parseArgs(parser)
def callback(packet: DetectionPacket):
visualizer = packet.visualizer
num = len(packet.img_detections.detections)
visualizer.add_text(f"Number of Objects: {num}", position=TextPosition.TOP_MID)
visualizer.draw(packet.frame)
cv2.imshow(f'frame {packet.name}', packet.frame)
with OakCamera(args=args) as oak:
color = oak.create_camera('color')
nn = oak.create_nn(args['config'], color, nn_type='yolo', spatial=True) # nn_type='yolo' decode_fn=decode
oak.visualize(nn, callback=callback)
oak.visualize(nn.out.passthrough, fps=True)
oak.start(blocking=True)
Also please specify the path to the blob in your json config. The following configuration worked in my case:
{
"model": {
"blob": "../models/yolov5n_coco_416x416_openvino_2021.4_6shave.blob"
},
"nn_config":
{
"output_format" : "detection",
"NN_family" : "YOLO",
"input_size": "416x416",
"NN_specific_metadata" :
{
"classes" : 80,
"coordinates" : 4,
"anchors" : [10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326],
"anchor_masks" :
{
"side52" : [0,1,2],
"side26" : [3,4,5],
"side13" : [6,7,8]
},
"iou_threshold" : 0.5,
"confidence_threshold" : 0.5
}
},
"mappings":
{
"labels":
[
"person",
"bicycle",
"car",
"motorbike",
"aeroplane",
"bus",
"train",
"truck",
"boat",
"traffic light",
"fire hydrant",
"stop sign",
"parking meter",
"bench",
"bird",
"cat",
"dog",
"horse",
"sheep",
"cow",
"elephant",
"bear",
"zebra",
"giraffe",
"backpack",
"umbrella",
"handbag",
"tie",
"suitcase",
"frisbee",
"skis",
"snowboard",
"sports ball",
"kite",
"baseball bat",
"baseball glove",
"skateboard",
"surfboard",
"tennis racket",
"bottle",
"wine glass",
"cup",
"fork",
"knife",
"spoon",
"bowl",
"banana",
"apple",
"sandwich",
"orange",
"broccoli",
"carrot",
"hot dog",
"pizza",
"donut",
"cake",
"chair",
"sofa",
"pottedplant",
"bed",
"diningtable",
"toilet",
"tvmonitor",
"laptop",
"mouse",
"remote",
"keyboard",
"cell phone",
"microwave",
"oven",
"toaster",
"sink",
"refrigerator",
"book",
"clock",
"vase",
"scissors",
"teddy bear",
"hair drier",
"toothbrush"
]
}
}
Thanks,
Daniil