The code path for the common progress of data sets and neural networks

The continuous adjustment of the following code can make the neural network and data set progress together

Insert picture description hereThe 5 classification is successfully divided into 7 classifications, that is to say, the model's ability will not be classified into this category.
However, people still use the model to force the 5 classifications of these pictures, so it is definitely not accurate

That is to say, this picture is neither 0 classification nor 1 classification, but people
only recognize 5 results after training the model , and naturally there are only 5 results. Although this picture is not any, it will still be considered as 5 categories. One, that is to say, the model is not wrong, but you have forcibly reduced its range and orientation.That is to say, the data you provided is annotated, just the types you think of, but the model can completely label your All the classifications of are found,
but if you do n’t visualize it, you do n’t know there are several categories that you did n’t think of at all,
but the model thinks of l,
so that the model can really be separated, but the human will has caused the model to be wrong. ,
So the next step will be to correct such errors and take the common progress of the model and data set
to solve a large amount of labeling time and the model does not achieve the results that humans want.

The above sum it up, there are some data set of data we do not need the class
below it removed

The following figure is the training data network that allows the true distribution of image classification.You can see that this data set should be labeled as 7 types
instead of 5 types
. In the correction category method, divide the data level into 7 categories, remove the categories that we do n’t want, continue to use the newly marked data level or use the data collection of
Insert picture description heredeclination to put your own pictures into the project, and change the data in readmist Process the code
Generate a txt file of the image label and path
First execute the code
training and then execute the manual classification of data in readminst cls_data ()
to get a similar classification as shown Insert picture description here
in the figure. Use the mouse to select two points in the blank space as the dividing line (clockwise Or vice versa, the dividing line should be next to the dividing line),
this format

[3.35,-6.27,10.72,-22.7,8.56,-2.69,21.89,-3.40,9.37,2.08,22.34,4.95,7.75,6.38,17.57,15.95,6.12,9.25,12.28,19.05,-1.25,7.34,-8.1,21.92,-3.15,-5.79,-9.0,-17.15]

After recording, close the image,
enter the above data into the console
, and it will be generated. A json file, the address of the picture has been stored in the list according to the above dividing line, and finally only the path needs to be read by itself Come out and write another
picture and store it in the corresponding file to complete, manual classification

The code is at
https://download.csdn.net/download/weixin_32759777/12328521

You can use the following code for manual segmentation

def get_path_and_dir(path):
    with open(path,"r") as f:
        data=json.load(f)
    for i ,one_path_list in enumerate(data["new_path_data"]):
        makedirs("image"+str(i))
        for one_path in one_path_list:
            with open(one_path,"rb") as f:
                data=f.read()
            with open("image"+str(i)+"/"+one_path.split("/")[-1],"wb") as f:
                f.write(data)

if __name__ == '__main__':
    # cls_data()
    get_path_and_dir("/home/chenyang/PycharmProjects/arc_face/new_data_path.json")

Insert picture description hereAfter classification, the pictures are not separated according to the dividing line, but are separated according to the above picture.
After inspection, it is found that the pictures are the same in front of each file. That is to say
, the problem with the
Insert picture description here
problem written by our cls_data () is all Pictures will be smaller than two lines AB

So all the confusion looks like concentric circles, the
actual concentric circles should be as shown
in the figure below,
Insert picture description here
so rewrite
cls_data ()

Insert picture description hereBasically, it is divided into four cases, according to the direction of the above picture

c_x_0 The outer point x on the starting point dividing line minus the inner point x
c_x_1 The outer point x on the ending dividing line minus the inner point x
x_0_1 The two dividing line focal points x
bring the x value to the starting point dividing line y value real_0
brings the x value to End point dividing line y value real_1
y actual value

c_x_0 >x_0_1
c_x_1 >x_0_1
y<real_1
y>real_0

c_x_1 <x_0_1 
 y>real_1
 y>real_0

c_x_0 <x_0_1
c_x_1 >x_0_1
y<real_1
y<real_0

c_x_1 <x_0_1 
y>real_1
y<real_0

code show as below


def cls_data():
    data=dis_data()
    draw_json(data[0],data[1])
    print("请在图中输入分割线的坐标(线上两个点坐标共计四个值),保留两位小数")
    print("输入的线要按照分割的顺序输入")
    line_data=json.loads(input("请按照说明输入数据这样的格式[1,2,3,4,5,65]"))
    line_data=numpy.array(line_data).reshape(-1,4).tolist()
    k_b_list=[]
    cls_index_path=[]
    for xy in line_data:
        k_b = y_kx_b(xy)
        cls_index_path.append([])
        k_b_list.append(k_b)
    k_b_list.append(k_b_list[0])
    cls_index_path.append([])
    index_x=-1
    set_path=[]
    for x,y in zip(data[0],data[1]):
        try:
            index_x+=1
            k_b_index=0
            for _ in range(len(k_b_list)):
                k_b_index+=1
                real_0=k_b_list[k_b_index-1][0]*x+k_b_list[k_b_index-1][1]
                real_1=k_b_list[k_b_index][0]*x+k_b_list[k_b_index][1]
                c_x_0=k_b_list[k_b_index-1][2]
                c_x_1=k_b_list[k_b_index][2]
                x_0_1=(k_b_list[k_b_index][1]-k_b_list[k_b_index-1][1])/(k_b_list[k_b_index-1][0]-k_b_list[k_b_index][0])

                # c_x_0大于x_0_1的y>real_0否则y<real_0
                # 当c_x_0 >x_0_1 ,c_x_1 >x_0_1的y<real_1  c_x_1 <x_0_1 y>real_1
                # 当c_x_0 <x_0_1 ,c_x_1 >x_0_1的y<real_1  c_x_1 <x_0_1 y>real_1

                if c_x_0 >x_0_1:
                    if c_x_1 >x_0_1:
                        if y>real_0 and y<real_1:
                            if data[2][data[0].tolist().index(x)] in set_path:
                                continue
                            else:
                                set_path.append(data[2][data[0].tolist().index(x)])
                                cls_index_path[k_b_index].append(data[2][data[0].tolist().index(x)])
                    else:
                        if y>real_0 and y>real_1:
                            if data[2][data[0].tolist().index(x)] in set_path:
                                continue
                            else:
                                set_path.append(data[2][data[0].tolist().index(x)])
                                cls_index_path[k_b_index].append(data[2][data[0].tolist().index(x)])

                else:
                    if c_x_1 > x_0_1:

                        if y<real_0 and y<real_1:
                            if data[2][data[0].tolist().index(x)] in set_path:
                                continue
                            else:
                                set_path.append(data[2][data[0].tolist().index(x)])
                                cls_index_path[k_b_index].append(data[2][data[0].tolist().index(x)])
                    else:
                        if y<real_0 and y>real_1:
                            if data[2][data[0].tolist().index(x)] in set_path:
                                continue
                            else:
                                set_path.append(data[2][data[0].tolist().index(x)])
                                cls_index_path[k_b_index].append(data[2][data[0].tolist().index(x)])

            print(index_x)
        except:
            pass
    with open("new_data_path.json", "w", encoding="utf-8") as f:
        json.dump({"new_path_data":cls_index_path}, f, ensure_ascii=False)
    # q=[-4.70, -6.42, -15.51, -27.40,1.92, -2.72,7,14,2.21, 3.45,8.1, 15.37,-1.87, 3.86,-7.82, 17.64,-6.75, 7.35,-11.03,12.90,-9.57, 4.88,-19.60, 7.14,-8.40, -1.07,-21.84, -1.28]
    #将坐标
    q=[3.35,-6.27,10.72,-22.7,8.56,-2.69,21.89,-3.40,9.37,2.08,22.34,4.95,7.75,6.38,17.57,15.95,6.12,9.25,12.28,19.05,-1.25,7.34,-8.1,21.92,-3.15,-5.79,-9.0,-17.15,-3.42,-9.62,-9.18,-28]


Published 285 original articles · praised 89 · 2.48 million views

Guess you like

Origin blog.csdn.net/weixin_32759777/article/details/105380273