onnx / onnx/models

The boundingbox from the ssd-10 model is inaccurate

Open
#470 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Bug Report

Which model does this pertain to?

ssd-10.onnx

Describe the bug

When using onnxruntime to load the ssd-10 model to infer the picture, the boundingbox is inconsistent with the actual.
image:coco/val2017/000000581317.jpg

Reproduction instructions

Do preprocess and postprocess refer to https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/ssd

System Information
OS Platform and Distribution (e.g. Linux Ubuntu 16.04): Linux VM-1-159-ubuntu 4.15.0-136-generic #140-Ubuntu SMP Thu Jan 28 05:20:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
ONNX version (e.g. 1.6):
ssd-10
Backend/Runtime version (e.g. ONNX Runtime 1.1, PyTorch 1.2):
Name: onnxruntime
Version: 1.8.1
Summary: ONNX Runtime is a runtime accelerator for Machine Learning models
Home-page: https://onnxruntime.ai
Author: Microsoft Corporation
Author-email: onnxruntime@microsoft.com
License: MIT License
Location: /usr/local/anaconda3/envs/ubuntu/lib/python3.8/site-packages
Requires: protobuf, numpy, flatbuffers
Required-by:

Provide a code snippet to reproduce your errors.

import onnx
from PIL import Image,ImageDraw,ImageFont

model = onnx.load('model.onnx')

postprocess
def proGetOutResults_ssd(self,input_obj,outputs_dict,output_names,input_prop):
        inobjs,outobjs=self.proGetOutImageNotResize(input_obj)
        bboxes=[]
        labels=[]
        scores=[]
        label_category = self.proGetOutCategory(input_prop)
        box=np.squeeze(outputs_dict[output_names[0]])
        score=np.squeeze(outputs_dict[output_names[2]].T)
        indices=np.squeeze(outputs_dict[output_names[1]].T)
        print(box,score,indices)
        # length=[np.sum(np.where(score>self.outputscore,1,0)),1][self.outputscore==0.0]
        length=1
        for id_x in range(length):
            labels.append(label_category[indices[id_x]-1])
            scores.append(score[id_x])
            bboxes.append(box[id_x])
        return inobjs,outobjs,bboxes,labels,scores

def proObject_Detection(self,outputs_dict,output_names,input_prop,input_obj):
        inobjs,outobjs,bboxes,labels,scores=postPro.funcdict[postPro.modelkind]["proGetOutResults"].__call__(input_obj,outputs_dict,output_names,input_prop)
        for i in range(len(bboxes)):
            cc=bboxes[i]
            ll=labels[i]
            ss=scores[i]
            self.outputresults[i]=[cc,ll,ss]
        self.proDrawPredicts_Detection(inobjs,outobjs)

def proDrawPredicts_Detection(self,inobjs,outobjs):
        img=Image.open(inobjs)
        img_draw=ImageDraw.Draw(img)
        for _,v in self.outputresults.items():
            x1,y1,x2,y2=postPro.funcdict[postPro.modelkind]["porGetOutBbox"].__call__(v[0],img.size)
            text_content=" {0}:{1:0.4%}".format(v[-2],v[-1])
            text_color=(0,0,0)
            rect_color=(173,255,47)
            text_font=self.outputfont
            text_size=12
            img_font=ImageFont.truetype(text_font,size=text_size, encoding="utf-8")
            tw,th=img_font.getsize(text_content)
            x3=x1+tw
            y3=y1+th
            text_coor=((x1,y1),(x3,y3))
            img_draw.rectangle(text_coor,fill=rect_color,outline=rect_color,width=1)
            coor_start=(x1,y1)
            img_draw.text(coor_start,text=text_content,fill=text_color,font=img_font)
            rect_coor=((x1,y1),(x2,y2))
            img_draw.rectangle(rect_coor,fill=None,outline=rect_color,width=1)

        img.show()
        img.save(outobjs)
...
Notes

image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ssd-10.onnx and reproduce the report using the COCO image coco/val2017/000000581317.jpg, ONNX Runtime 1.8.1, and the supplied Python postprocessing code. Compare its preprocessing and postprocessing with the SSD instructions linked in the issue, then verify that the resulting bounding boxes align with the image objects.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.