ZFTurbo / Weighted-Boxes-Fusion

Set of methods to ensemble boxes from different object detection models, including implementation of "Weighted boxes fusion (WBF)" method.
MIT License
1.7k stars 237 forks source link

All Performance Metrics are 0 #36

Open ozanpkr opened 2 years ago

ozanpkr commented 2 years ago

I wanna use this repo with mmdetection result.I edited Json and converted to CSV format.However I get 0 for mAP and Recall. I can share my csv and ground_truth.json files via drive link.In addition you can see my detection output for model_1 below; out_det

You can see json2csv script on below;

with open('fsaf_r50.csv', 'w', encoding='UTF8',newline='') as ff:
    writer = csv.writer(ff)
    writer.writerow(header)
    for i in range(0,len(data)):

            real_data=data[i]['bbox']

            real_data[2]=real_data[0]+real_data[2]
            real_data[3]=real_data[1]+real_data[3]

            normalized_arr = preprocessing.normalize([real_data])

            image_id=data[i]['image_id'][:]
            csv_data = [int(image_id), normalized_arr[0][0],normalized_arr[0][1],normalized_arr[0][2],normalized_arr[0][3], data[i]['score'],data[i]['category_id'],]
            writer.writerow(csv_data)

I think normalization process is wrong my code or ground_truth.json configuration is false.Could you help me ? You can access all code with this URL:

https://github.com/ozanpkr/Weighted-Boxes-Fusion/tree/master/ozan

Could you normalize this bbox? format=[x1,y1,width,height] !!!(x1,y1) refer to upper left [148,186,72,96] =??

ZFTurbo commented 2 years ago

You need to convert boxes in x1, y1, x2, y2 format, then normalize (using image width and height).

xn1 = x1 / image_width
yn1 = y1 / image_height
xn2 = (x1 + width) / image_width
yn2 = (y1 + height) / image_height

then you can apply WBF.

ozanpkr commented 2 years ago

You need to convert boxes in x1, y1, x2, y2 format, then normalize (using image width and height).

xn1 = x1 / image_width
yn1 = y1 / image_height
xn2 = (x1 + width) / image_width
yn2 = (y1 + height) / image_height

then you can apply WBF.

Thanx for quick reply :) I'll let you know about results