Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.54k stars 4.18k forks source link

need yolo inference code #5772

Closed xalteropsx closed 2 weeks ago

xalteropsx commented 2 weeks ago

after getting the out0

what we do next ? how can we get xyxy cause the output is not readable format

Baiyuetribe commented 2 weeks ago

see: https://github.com/search?q=yolo%20ncnn&type=repositories Over 200 cases.

xalteropsx commented 2 weeks ago

@Baiyuetribe


def test_inference():

    imagex = cv2.imread('pandwithmen.jpg')

    image = preprocess(imagex)
    out = []

    net = ncnn.Net() 

    net.load_param("Face.param")
    net.load_model("Face.bin")

    with net.create_extractor() as ex:
        ex = net.create_extractor()
        ex.input("in0", ncnn.Mat(image))

        _, out0 = ex.extract("out0")
        outputs = np.array(out0)
        rows = outputs.shape[0]
        boxes = []
        scores = []
        class_ids = []
        x_factor = imagex.shape[1] / 640
        y_factor = imagex.shape[0] / 640

        for i in range(rows):
            classes_scores = outputs[i][4:]
            class_id = np.argmax(classes_scores)
            max_score = np.amax(classes_scores)

            if max_score >= 0.1:
                x, y, w, h = outputs[i][0], outputs[i][1], outputs[i][2], outputs[i][3]
                left = int((x - w / 2) * x_factor)
                top = int((y - h / 2) * y_factor)
                width = int(w * x_factor)
                height = int(h * y_factor)

                class_ids.append(class_id)
                scores.append(max_score)
                boxes.append([left, top, width, height])

        indices = cv2.dnn.NMSBoxes(boxes, scores, 0.1, 0.5)
        for i in indices:
            box = boxes[i]
            draw_detections(imagex, box,i)
xalteropsx commented 2 weeks ago

seems like my model was currpted nvm

xalteropsx commented 1 week ago

@Baiyuetribe sorry for tagging how can we pass int arugment on pnxx

pnnx resnet18.pt inputshape=[1,3,224,224],[i want here any float here like threshold]

Baiyuetribe commented 1 week ago

@Baiyuetribe sorry for tagging how can we pass int arugment on pnxx

pnnx resnet18.pt inputshape=[1,3,224,224],[i want here any float here like threshold]

eg:./pnnx resnet18.pt inputshape=[1,3,224,224]f32,[1,32]i64 see more: https://github.com/pnnx/pnnx

xalteropsx commented 1 week ago

thnx for super fast reply >.</ awesome i will check it soon gonna have to go for dinner