onnx / models

A collection of pre-trained, state-of-the-art models in the ONNX format
http://onnx.ai/models/
Apache License 2.0
8.01k stars 1.41k forks source link

The boundingbox from the ssd-10 model is inaccurate #470

Open wangxudong-cq opened 3 years ago

wangxudong-cq commented 3 years ago

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

wangxudong-cq commented 3 years ago

output bbox: [[ 0.636135 0.27017403 0.9825909 1.1217589 ] [ 0.637047 0.40575445 0.67029864 0.49792147] [ 0.755039 0.28670368 0.9688152 0.9758347 ] [ 0.8456569 0.6002558 0.8926159 0.7711937 ] [ 0.83193415 0.5609849 0.90308326 0.8282661 ] [ 0.6389635 0.1664187 1.0077784 0.7252742 ] [ 0.4421909 0.18554306 0.9807277 0.937438 ] [ 0.8815078 0.28679544 1.0003009 0.8998993 ] [ 0.70137334 0.15421823 0.943398 0.54634356] [ 0.7370353 0.2181699 0.8310981 0.51400816] [ 0.6194212 0.31667832 0.861468 0.80960274] [ 0.58447987 0.37941903 0.7895699 1.0084097 ] [ 0.6204029 0.4496738 0.89345914 1.0222689 ] [ 0.89035803 0.3924658 0.9710075 0.74518085] [ 0.75845176 0.15235904 0.90970045 0.33217654] [ 0.75752527 0.27155966 0.9677394 0.619323 ] [ 0.73501873 0.15423921 0.83113635 0.37917897] [ 0.83695126 0.35980636 0.9983692 0.6635006 ] [ 0.6399825 0.13384376 0.86396235 0.58241063] [ 0.7720387 0.177227 0.888613 0.45907384] [ 0.78400517 0.58491194 0.8711133 0.8774071 ] [ 0.6468613 0.48114505 0.66044056 0.5074215 ] [ 0.69439685 0.5584887 0.94179475 0.99168324] [ 0.72120166 0.20578834 0.8637662 0.40847018] [ 0.84643036 0.25885546 0.9521341 0.56348735] [ 0.5399124 0.35981464 0.81259006 0.73262405] [ 0.7578716 0.38963258 0.9603611 0.7303679 ] [ 0.69278836 0.20032993 0.79341066 0.46598443] [ 0.77497584 0.25533554 0.8672587 0.5630995 ] [ 0.61206657 0.15582655 1.0361688 0.4550209 ] [ 0.7672669 0.6386427 0.98944336 0.99775594] [ 0.6508909 0.4759988 0.6669963 0.50395525] [ 0.6056605 0.4894442 0.8015618 0.83620995] [ 0.6433848 0.4131813 0.68670106 0.53081083] [ 0.8137388 0.26607454 0.9092454 0.57044065] [ 0.65352774 0.45704895 0.750788 0.7792857 ] [ 0.5613413 0.42433792 0.98373544 0.7556371 ] [ 0.8394314 0.7724386 0.95572186 0.9942209 ] [ 0.39269075 0.16887866 1.1013678 0.5397251 ] [-0.00221208 0.5295025 0.08822438 0.650427 ] [ 0.90330434 0.31178945 0.9832412 0.62916577] [ 0.5009095 0.19330707 0.8741384 0.6981163 ] [ 0.6558653 0.57744193 0.8661295 0.88051975] [ 0.6776213 0.42738795 0.8884786 0.7689601 ] [ 0.7146278 0.28504238 0.85291106 0.47709814] [ 0.83717 0.6332175 0.879895 0.788065 ] [ 0.7802941 0.11116564 0.9850462 0.5130722 ] [ 0.63509065 0.4906131 0.65158373 0.5222845 ] [ 0.69499946 0.14879093 0.80574834 0.3545746 ] [ 0.87614954 0.40676045 0.9892473 0.59364116] [ 0.61353344 0.5103026 0.7216248 0.79891104] [ 0.5366598 0.6387966 1.0222553 1.012531 ] [ 0.83265036 0.2707351 0.864747 0.35762897] [ 0.93804294 0.36158812 1.0035062 0.6657306 ] [ 0.64537114 0.49989912 0.6587973 0.5271086 ] [ 0.766495 0.485357 0.8789114 0.7576522 ] [ 0.83678555 0.27164137 0.8563379 0.29585087] [ 0.12069435 0.86909187 0.2311204 1.0346155 ] [ 0.6363736 0.4759765 0.6520204 0.511937 ] [ 0.8424795 0.18044335 0.9512759 0.44332063] [ 0.639148 0.6659771 0.8362601 1.0310218 ] [ 0.77014005 0.47061664 0.86884415 0.787381 ] [ 0.8144563 0.6251872 0.89412683 0.7927719 ] [ 0.8086512 0.40049556 0.9144689 0.65639627] [ 0.6837126 0.17390501 0.92869234 0.2798325 ] [ 0.7209618 0.7963938 0.9674095 0.9994511 ] [ 0.8268881 0.43547383 1.0024091 0.9936253 ] [ 0.84433234 0.26899296 0.86885905 0.2952559 ] [ 0.17320675 0.5857354 0.18745458 0.6249054 ] [ 0.582848 0.08603723 1.0250121 0.3484282 ] [ 0.8171238 0.17467676 0.921587 0.30942905] [ 0.05292076 0.7605937 0.07008658 0.79051214] [ 0.80672 0.19881059 0.92279327 0.47662926] [ 0.6827859 0.44105196 0.78352004 0.7486383 ] [ 0.64469355 0.48459113 0.65678793 0.50121385] [ 0.69997483 0.54417074 0.773362 0.93342924] [ 0.63516444 0.39914265 0.70033735 0.5047113 ] [ 0.84071803 0.58608586 0.87177134 0.75624996] [ 0.6626182 0.1416865 0.8769881 0.376486 ] [ 0.36107165 0.31552216 1.1513574 0.6954012 ] [ 0.8537516 0.10826025 0.950298 0.3373359 ] [ 0.19137871 0.59093237 0.20105365 0.6162127 ] [ 0.87716174 0.3198204 0.9910214 0.51982224] [ 0.6509218 0.4977928 0.66708016 0.5242017 ] [ 0.41239315 0.2684186 0.4552247 0.35817945] [ 0.00250209 0.48310107 0.13209224 0.5423724 ] [ 0.8384021 0.27025664 0.8620433 0.30719858] [ 0.68610483 0.3143419 0.79862934 0.5607724 ] [ 0.0559132 0.7364871 0.07891523 0.7860686 ] [ 0.05698168 0.3002094 0.1595367 0.4048661 ] [ 0.84591275 0.2712167 0.86475724 0.28738874] [ 0.20382558 0.00792097 0.257547 0.09435863] [ 0.25764456 0.6302352 0.3628746 0.75997686] [ 0.66302013 0.14680831 0.7524296 0.4104178 ] [ 0.77039075 0.1560618 0.87457776 0.27326006] [ 0.781386 0.4527378 0.9291148 0.6282916 ] [ 0.47167602 0.29361516 0.89274395 0.5632195 ] [ 0.8439921 0.22084233 0.8671019 0.2637948 ] [ 0.8371048 0.26801392 0.8712853 0.3195301 ] [ 0.49062523 0.31663185 0.71638715 0.8344247 ] [ 0.63694525 0.39360538 0.75393236 0.6364129 ] [ 0.6963121 0.27921012 0.73188263 0.39963827] [ 0.09763657 0.3377037 0.13205437 0.37658936] [ 0.8065551 0.35177603 0.9909764 0.48501155] [-0.00155313 0.47203898 0.18532318 0.6951635 ] [ 0.19150575 0.5911469 0.20395412 0.63080114] [ 0.04585015 0.6672116 0.05630774 0.6921937 ] [ 0.13089399 0.00872225 0.23122637 0.22048715] [ 0.8921467 0.5781746 0.97657084 0.8932215 ] [ 0.8338062 0.2857746 0.85613614 0.33730704] [ 0.17294563 0.01753555 0.28052843 0.07854828] [ 0.5472854 0.5289795 0.6533267 0.6538611 ] [ 0.86375636 0.36116403 0.9520866 0.49661857] [ 0.68202645 0.35797793 1.0820205 0.6510168 ] [ 0.19447264 0.7614393 0.20640942 0.7868146 ] [ 0.7425703 0.43176508 0.8259337 0.7680676 ] [ 0.72918147 0.4680603 0.93875915 0.7770198 ] [ 0.74914753 0.13673727 0.9364561 0.2555151 ] [ 0.8302977 0.2995751 0.84677994 0.32367748] [-0.00510927 0.53240526 0.17558804 0.6348064 ] [ 0.72035116 0.12279887 0.86888057 0.2828759 ] [ 0.08542752 0.8762204 0.19118267 1.0342585 ] [ 0.05525284 0.8525661 0.13944766 1.068574 ] [ 0.08113354 0.3211131 0.10478382 0.35117942] [ 0.85990995 0.23212418 0.8884422 0.2857379 ] [ 0.7949507 0.68278354 0.83790886 0.8091113 ] [ 0.31286302 0.18045112 0.3192902 0.1905658 ] [ 0.6364974 0.4133377 0.75705254 0.6631521 ] [ 0.8746894 0.57533836 1.013524 1.0658519 ] [ 0.0067625 0.09803329 0.08792751 0.40161973] [ 0.19446398 0.5887428 0.2044575 0.6077723 ] [ 0.09265735 0.31381437 0.13372666 0.3546656 ] [ 0.6881525 0.32611609 0.8880207 0.44426036] [ 0.74903834 0.19293188 0.8459555 0.31478846] [ 0.80689627 0.29382333 0.83229846 0.33528742] [ 0.80081666 0.8088707 0.91060114 1.0135825 ] [ 0.7991798 0.2770193 0.82541 0.34755793] [ 0.80039346 0.20198908 0.8275188 0.24616438] [ 0.6456502 0.46662888 0.65748185 0.48613712] [ 0.8444954 0.19909436 0.8686714 0.24119702] [ 0.10190147 0.3625794 0.13111418 0.39239877] [ 0.01028233 0.84913456 0.10296969 1.0526439 ] [ 0.6548782 0.24172297 0.75696415 0.47295836] [ 0.862541 0.6189732 0.90444034 0.7557172 ] [ 0.8960155 0.13227174 0.9880265 0.38135317] [ 0.82887745 0.84141415 0.9349685 0.96018356] [ 0.81152415 0.5898943 0.99842966 0.88694596] [ 0.7381766 0.22860588 0.92346454 0.3619895 ] [ 0.7429851 0.8540581 0.8927667 1.0065042 ] [ 0.29713893 0.601651 0.48236054 0.7688858 ] [ 0.13961226 0.7974314 0.21946445 1.0184746 ] [ 0.16183338 0.04019856 0.28521255 0.25807184] [ 0.6584229 0.2773169 0.8454638 0.41441694] [ 0.8047142 0.40349746 0.9861338 0.51704895] [ 0.604926 0.61695194 0.80381405 0.93335104] [ 0.08470364 0.02841412 0.18445872 0.26244307] [ 0.8597018 0.64140195 0.99050254 0.8270809 ] [ 0.04641365 0.7470146 0.06930462 0.77699035] [ 0.29222775 0.6631294 0.3373657 0.72792214] [ 0.4243766 0.29182282 0.4725346 0.39574865] [ 0.17480889 0.77878517 0.26358905 0.99592894] [ 0.8697808 0.84868807 0.9091213 0.9503606 ] [ 0.15288587 0.8044427 0.3660593 1.0007405 ] [ 0.6483067 0.467178 0.6957303 0.50637716] [ 0.7392841 0.36138085 0.9256211 0.48658046] [ 0.8483105 0.46178797 0.88754404 0.5731604 ] [ 0.04897667 0.6650081 0.06008455 0.6872501 ] [ 0.82194704 0.18210475 0.84772867 0.22653978] [ 0.82349086 0.20522872 0.8475647 0.24098417] [ 0.0854927 0.28187314 0.14377403 0.31052795] [ 0.65010506 0.5173504 0.66584474 0.5403648 ] [ 0.10509908 0.04318602 0.15899071 0.09057728] [ 0.03012263 0.2727162 0.14104256 0.38007054] [ 0.04863563 0.7595211 0.0649081 0.78726053] [ 0.32402816 0.13613842 0.8102921 0.6059849 ] [ 0.08557928 0.30186316 0.11048856 0.33330104] [ 0.4601335 0.49784166 0.903117 0.7994922 ] [ 0.8261095 0.27889806 0.8504014 0.347789 ] [ 0.47675124 0.34932604 0.5114526 0.40917096] [ 0.67709464 0.2922349 0.9385782 0.39198852] [ 0.10454208 0.5852499 0.34010127 0.8073107 ] [ 0.6470457 0.46086204 0.663263 0.49156213] [ 0.67200965 0.19325395 0.85840183 0.32528496] [ 0.01798116 0.2938395 0.18471886 0.4693393 ] [ 0.34817785 0.5179741 1.0528326 0.98033935] [ 0.7828021 0.2857603 0.80096996 0.35027435] [ 0.7256727 0.1578394 0.82014644 0.2825226 ] [ 0.62489 0.41563588 0.7925659 0.5656446 ] [ 0.94305086 0.06530754 1.0038437 0.39691997] [ 0.51038694 0.38278535 1.0003463 0.6291305 ] [ 0.7979037 0.17707819 0.8282886 0.23707637]] output score: [0.93811536 0.48742655 0.25458238 0.16140266 0.14642908 0.1430038 0.13373509 0.1323816 0.13114513 0.12916343 0.12423059 0.11858726 0.11669458 0.11616195 0.1140703 0.11200613 0.10629988 0.10614701 0.10607288 0.10500607 0.10438517 0.10316112 0.10129891 0.09659627 0.09652527 0.09583476 0.09449784 0.09416656 0.09245645 0.09123572 0.08919138 0.08802727 0.08587054 0.0856275 0.08495302 0.08486125 0.08336546 0.08295689 0.0810746 0.07990329 0.07949192 0.07942604 0.0785858 0.07821784 0.07759993 0.07747559 0.07730237 0.07621557 0.0754611 0.07526223 0.07515799 0.07488894 0.07486006 0.07390484 0.07384872 0.07335129 0.07079539 0.06987862 0.06911505 0.06911425 0.06905215 0.06841458 0.06835768 0.06817658 0.06795034 0.06789093 0.06787648 0.06776546 0.0677281 0.06755637 0.06664344 0.0664937 0.0664644 0.06643101 0.06634286 0.06567504 0.0656262 0.0652872 0.06503497 0.06489342 0.06439272 0.06427186 0.06415143 0.06384333 0.06375991 0.0637424 0.06369545 0.06359639 0.06343096 0.06317139 0.06302308 0.06286406 0.06278442 0.0626485 0.06256755 0.06238819 0.06230576 0.06230463 0.06172173 0.06151831 0.06128956 0.06101724 0.06097448 0.06092166 0.0609166 0.06077686 0.06042746 0.05996291 0.05989325 0.05984771 0.05973238 0.05967856 0.05964614 0.05951371 0.05901136 0.05853061 0.05836636 0.05829314 0.05819492 0.05816795 0.05813444 0.05808662 0.05804389 0.05789478 0.05748546 0.0574547 0.05736001 0.05733716 0.05726331 0.05725385 0.0567075 0.05670445 0.0565859 0.05652702 0.05642898 0.05633244 0.05592711 0.05584712 0.05576639 0.05565544 0.05550427 0.0554961 0.05546142 0.05521764 0.05514949 0.05509077 0.05502706 0.054519 0.05446845 0.0543601 0.05431659 0.05374492 0.05358487 0.05357658 0.053198 0.05317064 0.05301224 0.05299707 0.05296018 0.05290198 0.05282758 0.05275538 0.05269979 0.05249407 0.05248727 0.05233311 0.05225116 0.05211063 0.05199976 0.05175759 0.05141206 0.05134885 0.05133321 0.05124668 0.05117919 0.05112861 0.05110259 0.05106949 0.05104892 0.05086302 0.05083352 0.05071766 0.05066827 0.05060521 0.05054874 0.05054289 0.05044907 0.05024472 0.05008757 0.05003132 0.05000408] output label: [ 1 68 1 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 28 33 1 1 1 1 1 1 1 1 1 33 1 68 1 1 1 1 1 5 1 1 1 1 1 28 1 33 1 1 1 1 68 1 33 27 68 1 33 1 1 28 28 1 1 1 1 68 1 1 1 15 1 1 33 1 68 28 1 1 1 1 1 33 1 26 68 1 15 3 68 15 51 1 1 25 1 1 68 1 35 1 3 1 5 1 15 1 57 68 15 51 1 1 1 1 27 1 68 5 1 1 1 3 1 28 15 1 1 1 1 3 1 1 68 1 68 1 33 1 3 1 1 28 1 1 57 1 27 51 1 1 1 1 1 1 57 15 51 1 1 1 59 68 1 28 15 1 1 9 33 15 3 15 34 3 1 68 1 1 59 33 1 3 1 68 1 35 1 1 1]