<gh_stars>0
import cv2 as cv


def load_net(cfg, weights):
    net = cv.dnn.readNetFromDarknet(cfg, weights)
    net.setPreferableBackend(cv.dnn.DNN_BACKEND_OPENCV)
    net.setPreferableTarget(cv.dnn.DNN_TARGET_CPU)

    return net


def load_classes(classesFile):
    with open(classesFile, 'rt') as f:
        classes = f.read().rstrip('\n').split('\n')

    return classes


# getting the names of output layers
def getOutputsNames(net):
    layersNames = net.getLayerNames()
    return [layersNames[i - 1] for i in net.getUnconnectedOutLayers()]