DeNA / PyTorch_YOLOv3

Implementation of YOLOv3 in PyTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is my code for [sorting the clusters according to areas] and [matching clusters with ANCH_MASK] right?

sisrfeng opened this issue · comments

Using k-means , I get Boxes:
[[0.0671875 0.09814815]
[0.07552083 0.11388889]
[0.05572917 0.08796296]
[0.24010417 0.17222222]
[0.32552083 0.26759259]
[0.0953125 0.12685185]
[0.05833333 0.08333333]
[0.12604167 0.14074074]
[0.18177083 0.15740741]]

Then copy and paste the numbers above. Then flatten the array by hand and get a list, a:
(The numbers of Boxes and a are from different results, so they are indepent. Just show that a is from Boxes)
a=[0.452,0.69375,0.116,0.104,0.22,0.512,0.1,0.30303703,0.038,0.064,0.056,0.16266667,0.41,0.33866667,0.192,0.224,0.83766667,0.78469484]

Training yolov3, the imgs are resized to 606x608
My imgs' size is 19201080. After k-means, **I can ignore 19201080, right?**

b=[round(608*x) for x in a]
boxes=[]
areas=[]
for i in range(0,len(a),2):
    boxes.append([b[i],b[i+1]])
    areas.append([b[i]*b[i+1]])
#print(boxes)
#print(areas)
new_areas=sorted(areas)
new_boxes=[]
#print(new_areas)
for i in range(0,len(boxes)):
    mylist=list(range(0,len(boxes)))
    for j in mylist:
        if new_areas[i]==areas[j]:
            new_boxes.append(boxes[j])
            mylist.remove(j)
print(new_boxes)

new_boxes=
[[23, 39], [34, 99], [71, 63], [61, 184], [117, 136], [134, 311], [249, 206], [275, 422], [509, 477]]

Should the following part of gaussian_yolov3_default.cfg be like this?

  ANCHORS: [[23, 39], [34, 99], [71, 63], 
            [61, 184], [117, 136], [134, 311],
            [249, 206], [275, 422], [509, 477]]
  ANCH_MASK: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]

Many thanks!