Git Product home page Git Product logo

Comments (4)

ibaiGorordo avatar ibaiGorordo commented on May 30, 2024

Without more context it is hard to tell

  • Where did you get yolov7.onnx?
  • Does it have the nms/postprocessing included?
  • Can you share the onnx model?
  • What image/video are you testing it with?

from onnx-yolov7-object-detection.

beratersari avatar beratersari commented on May 30, 2024

I fixed that. In my case, the output of onnx model has three outputs. Onnx models which you shared in the read.me file just concatenate these three outputs. I solved by adding some script to concatenate these outputs. You can see the last layer of my onnx model below.
image

I also added these first seven lines to the YOLOV7.py file to concatenate the outputs shown in the image above. That function is in the 72 th line.

def process_output(self, output):
        predictions0 = np.squeeze(output[0])
        predictions1 = np.squeeze(output[1])
        predictions2 = np.squeeze(output[2])
        
        predictions0=predictions0.reshape(-1, predictions0.shape[-1])
        predictions1=predictions1.reshape(-1, predictions1.shape[-1])
        predictions2=predictions2.reshape(-1, predictions2.shape[-1])
        
        predictions = np.concatenate((predictions0, predictions1,predictions2), axis=0)
        
        # Filter out object confidence scores below threshold
        obj_conf = predictions[:, 4]
        predictions = predictions[obj_conf > self.conf_threshold]
        
        obj_conf = obj_conf[obj_conf > self.conf_threshold]

        # Multiply class confidence with bounding box confidence
        predictions[:, 5:] *= obj_conf[:, np.newaxis]

        # Get the scores
        scores = np.max(predictions[:, 5:], axis=1)
        print(scores)
        # Filter out the objects with a low score
        predictions = predictions[scores > self.conf_threshold]
        scores = scores[scores > self.conf_threshold]
        print(predictions)
        print("predictions result",predictions.shape)
        print("scores result",scores.shape)

        if len(scores) == 0:
            return [], [], []

        # Get the class with the highest confidence
        class_ids = np.argmax(predictions[:, 5:], axis=1)

        # Get bounding boxes for each object
        boxes = self.extract_boxes(predictions)
        print(boxes)

        # Apply non-maxima suppression to suppress weak, overlapping bounding boxes
        indices = nms(boxes, scores, self.iou_threshold)
        print(indices)
        print(scores)
        return boxes[indices], scores[indices], class_ids[indices]

Now,I am not getting any bbox output from the visualizer. I guess there is a problem in my onnx file. Which onnx converter did you use to convert .pt file to .onnx file. I used the converter in the yolov7 repository (https://github.com/WongKinYiu/yolov7/blob/main/export.py) . But the last layer isn't like yours last layer. Also, I am getting warning while converting. If you share your onnx converter scirpt I will be very pleasure. Also, could you state onnxruntime version? Thanks in advance.

from onnx-yolov7-object-detection.

beratersari avatar beratersari commented on May 30, 2024

https://drive.google.com/file/d/1m3y6dlm78J_WvVXHKuIARBkzqwBqRyFw/view?usp=sharing (Coverted yolov7,pt file in yolov7 repository)
This onnx model is not same as the photo which I shared. However, I also could not get any bounding box output for this onnx model. It just shows the image without any bboxes. I also tried to use your yolov7-tiny_480x640.onnx model. It easily detects the cars in the photo.

I tested it with this image
1470848884_42a8

from onnx-yolov7-object-detection.

ibaiGorordo avatar ibaiGorordo commented on May 30, 2024

Sorry for the delay, looking at that output, it looks like an issue during export, make sure to add the "--grid" parameter when you export the model.

from onnx-yolov7-object-detection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.