广东电网智慧现场作业挑战赛 赛道一:识别佩戴绝缘手套
从日本回来以后身体一直不是很好,算上隔离了近一个月时间还是没有缓过来。
趁着有时间,也是为了找工作复习一下目标识别。
前几天有个网友叫我打一个小比赛,我一看距离截止日期还有3天。
简单的用fasterrcnn,efficientdet,yolov5跑了一下,还没细看就要提交了。
时间实在是太紧,也没有什么共享资料,比赛就没有价值。
今天是6月27日,距离这个天池比赛截至还有10天。好好的做一下比赛,然后整理简历准备找工作了。
首先看了一下数据和评估标准
评估标准
总成绩=2 * mAP * mAR / (mAP + mAR)
排行榜第一刷到了0.9697
先用yolov5跑一次试试
因为跟yolov5的数据格式要求不一样,所以还是先转数据
测试一下读取,utf8没有问题。
然后把需要的数据提取出来,按照项目需要的格式排列。
对于项目https://github.com/ultralytics/yolov5
创建一个labels文件夹,对于每张图片,创建一个对应的txt文件,然后按行写入[label, x, y, w, h]
One row per object
Each row is class x_center y_center width height
format.
Box coordinates must be in normalized xywh format (from 0 - 1). If your boxes are in pixels, divide x_center
and width
by image width, and y_center
and height
by image height.
Class numbers are zero-indexed (start from 0).
参照https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data
这里一个好的习惯,千万不要看csdn上面写的东西,误人子弟。
输入数据
badge:监护袖章(只识别红色修章)
person:图中出现的所有在场人员
glove:绝缘手套(橡胶材质)
wrongglove:未佩戴绝缘手套(其他手套或裸露手掌)
operatingbar:操作杆
powerchecker:验电笔
首先根据比赛的数据说明,一共是6类。
提交数据
选手需要提交的测试结果为以下几类,且图像的category_id应与下方的注释保持相同:
guarder(监护人员)
gloveperson(规佩戴绝缘手人员)
wronggloveperson(不合规佩戴绝缘手套人员)
operator(有手持工具人员)
国内的氛围比不上kaggle,基本没有什么人分享kernel。
整个论坛就只有一个eda的notebook介绍。
https://tianchi.aliyun.com/notebook-ai/detail?spm=5176.12586969.1002.3.15f57bb2Mu6OQR&postId=234520
数据
划分train, val
首先第一个版本,在不考虑类平衡问题的前提下(认为原数据是随机的),手动划分了200多个验证集。
跑了1000多个程序出错
数据集里有一个坏文件,删掉。
经过处理还是有损坏的文件
train: Scanning ‘c:\tianchi\train\labels’ images and labels…2044 found, 0 missing, 4 empty, 358 corrupted: 100%|██████████| 2402/2402 [00:04<00:00, 519.57it/s]
corrupted在官方的issue里面大概是说标注有误,看了一下源码判断的地方和出问题的图片,没有发现什么问题。
在脚本里重新修改了一下,用opencv读取然后保存图片
train: Scanning ‘c:\tianchi\train\labels’ images and labels…2402 found, 0 missing, 4 empty, 0 corrupted: 100%|██████████| 2402/2402 [00:09<00:00, 261.62it/s]
代码
1 2 3 4 5 6 7 8 9 import csvimport pandas as pdimport codecsimport jsonimport cv2import numpy as npimport os%pylab inline
1 2 3 4 5 6 keys={"badge" : 0 , "person" : 1 , "glove" : 2 , "wrongglove" : 3 , "operatingbar" : 4 , "powerchecker" : 5 } train_df = pd.read_csv("1train_rname.csv" , header=None , usecols=[4 ,5 ]) train_df.columns = ["image_name" , "result" ] train_df["result" ] = train_df["result" ].apply(json.loads) train_df["image_name" ] = "c:/tianchi/" + train_df['image_name' ]
1 2 train_list = os.listdir("c:/tianchi/train_images" ) val_list = os.listdir("c:/tianchi/val_images" )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 for idx in range(len(train_df)): image_name = train_df['image_name' ].iloc[idx] label_path = "" image_path = "" if str(image_name[20 :]) not in train_list and str(image_name[20 :]) not in val_list: continue img = cv2.imread(train_df['image_name' ].iloc[idx]) if str(image_name[20 :]) in train_list: label_path = "c:/tianchi/train/labels/" + image_name[20 :-4 ] + ".txt" image_path = "c:/tianchi/train/images/" + image_name[20 :] cv2.imwrite(image_path, img) elif str(image_name[20 :]) in val_list: label_path = "c:/tianchi/val/labels/" + image_name[20 :-4 ] + ".txt" image_path = "c:/tianchi/val/images/" + image_name[20 :] cv2.imwrite(image_path, img) else : continue width = img.shape[1 ] height = img.shape[0 ] with open(label_path, 'a' ) as f: for item in train_df['result' ].iloc[idx]['items' ]: label = keys[item['labels' ]['标签' ]] x1, y1, x2, y2 = np.array(item['meta' ]['geometry' ]).astype(int) w = x2 - x1 h = y2 - y1 fx = float((x1+x2) / (2 * width)) fy = float((y1+y2) / (2 * height)) fw = float(w / width) fh = float(h / height) f.write(str(label)) f.write(" " ) f.write(str(fx)) f.write(" " ) f.write(str(fy)) f.write(" " ) f.write(str(fw)) f.write(" " ) f.write(str(fh)) f.write("\n" ) f.close()
baseline运行结果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 0 /299 3.84 G 0.1029 0.07955 0.04785 0.2303 10 1280 0.1794 0.01856 0.003714 0.0005819 0.09875 0.06769 0.04327 1 /299 3.81 G 0.09495 0.07529 0.03695 0.2072 6 1280 0.2508 0.09228 0.0193 0.004221 0.08998 0.06778 0.0301 2 /299 3.81 G 0.08886 0.069 0.02908 0.1869 7 1280 0.4022 0.2546 0.05995 0.01296 0.08223 0.06133 0.02489 3 /299 3.81 G 0.0807 0.06841 0.02456 0.1737 3 1280 0.5623 0.2351 0.1986 0.05546 0.07462 0.0532 0.01825 4 /299 3.81 G 0.07343 0.06437 0.01975 0.1576 35 1280 0.6199 0.3289 0.2922 0.09735 0.067 0.05142 0.01586 5 /299 3.81 G 0.06886 0.06258 0.0173 0.1487 8 1280 0.6333 0.3904 0.3876 0.1369 0.06287 0.05007 0.01274 6 /299 3.81 G 0.06462 0.06036 0.01547 0.1404 8 1280 0.4733 0.4914 0.4528 0.1744 0.05914 0.04958 0.01091 7 /299 3.81 G 0.06194 0.0589 0.01366 0.1345 10 1280 0.5511 0.4722 0.4839 0.193 0.05898 0.04609 0.01136 8 /299 3.81 G 0.05922 0.05852 0.01256 0.1303 19 1280 0.5983 0.539 0.5602 0.2082 0.05545 0.04457 0.008686 9 /299 3.81 G 0.05857 0.0561 0.01165 0.1263 17 1280 0.5987 0.5831 0.5878 0.2537 0.0535 0.04473 0.008247 10 /299 3.81 G 0.05633 0.05594 0.01097 0.1232 30 1280 0.6585 0.5728 0.5952 0.2737 0.05213 0.04283 0.008062 11 /299 3.81 G 0.05474 0.05495 0.01059 0.1203 16 1280 0.6364 0.6027 0.6166 0.3012 0.05003 0.04307 0.007838 12 /299 3.81 G 0.05336 0.05255 0.009791 0.1157 7 1280 0.6966 0.5784 0.6342 0.3067 0.05058 0.04174 0.007107 13 /299 3.81 G 0.05294 0.05311 0.009597 0.1157 23 1280 0.707 0.5807 0.6534 0.3106 0.04825 0.04194 0.00636 14 /299 3.81 G 0.05128 0.05227 0.009292 0.1128 16 1280 0.6764 0.6328 0.6656 0.3332 0.04788 0.04119 0.006946 15 /299 3.81 G 0.05086 0.05106 0.008387 0.1103 23 1280 0.6834 0.6562 0.6697 0.3406 0.0468 0.0408 0.006281 16 /299 3.81 G 0.04929 0.05087 0.008293 0.1085 20 1280 0.7727 0.6577 0.7131 0.3614 0.0455 0.03971 0.005888 17 /299 3.81 G 0.04875 0.0502 0.008002 0.107 12 1280 0.6868 0.708 0.7131 0.3758 0.04506 0.03969 0.005559 18 /299 3.81 G 0.04811 0.04973 0.007947 0.1058 29 1280 0.8123 0.657 0.7311 0.3781 0.04432 0.03949 0.005373 19 /299 3.81 G 0.0475 0.04864 0.007543 0.1037 5 1280 0.7419 0.7025 0.7296 0.3851 0.04427 0.03898 0.006154 20 /299 3.81 G 0.04656 0.04867 0.007397 0.1026 7 1280 0.7246 0.714 0.7353 0.4049 0.04312 0.03806 0.005024 21 /299 3.81 G 0.04602 0.04769 0.006865 0.1006 14 1280 0.7557 0.7086 0.74 0.394 0.04289 0.03824 0.004749 22 /299 3.81 G 0.04548 0.04672 0.00677 0.09897 16 1280 0.7978 0.6955 0.7505 0.4065 0.0425 0.03794 0.005085 23 /299 3.81 G 0.04459 0.04663 0.006668 0.09789 18 1280 0.7268 0.7289 0.7381 0.4118 0.04233 0.03796 0.004869 24 /299 3.81 G 0.04434 0.04613 0.006386 0.09686 17 1280 0.8032 0.6971 0.7605 0.4261 0.0414 0.03766 0.004423 25 /299 3.81 G 0.04374 0.04595 0.006362 0.09605 11 1280 0.7662 0.7299 0.7581 0.4353 0.04114 0.03725 0.00435 26 /299 3.81 G 0.04309 0.04587 0.006157 0.09512 12 1280 0.8114 0.7199 0.7695 0.4081 0.04234 0.03723 0.004599 27 /299 3.81 G 0.04329 0.04539 0.006163 0.09484 28 1280 0.7972 0.7551 0.7887 0.4385 0.04003 0.03707 0.00407 28 /299 3.81 G 0.04265 0.04568 0.005977 0.09431 14 1280 0.8015 0.741 0.7759 0.4383 0.0398 0.0367 0.004652 29 /299 3.81 G 0.04273 0.0455 0.006052 0.09428 19 1280 0.8109 0.7214 0.7763 0.4441 0.04021 0.03649 0.004764 30 /299 3.81 G 0.04187 0.04426 0.005601 0.09173 31 1280 0.8179 0.7465 0.7908 0.4526 0.03961 0.03686 0.003835 31 /299 3.81 G 0.04162 0.04388 0.005483 0.09098 18 1280 0.7949 0.7385 0.7755 0.4464 0.04002 0.03686 0.004671 32 /299 3.81 G 0.04151 0.04424 0.005883 0.09163 10 1280 0.7723 0.7721 0.7888 0.4579 0.03926 0.03611 0.004822 33 /299 3.81 G 0.04111 0.04368 0.005504 0.0903 21 1280 0.8289 0.7678 0.8179 0.458 0.03943 0.03592 0.004181 34 /299 3.81 G 0.04028 0.04248 0.005416 0.08818 6 1280 0.8221 0.768 0.8111 0.4808 0.03845 0.03619 0.00405 35 /299 3.81 G 0.04072 0.04353 0.005427 0.08968 6 1280 0.8435 0.7466 0.8104 0.4755 0.03874 0.03599 0.003859 36 /299 3.81 G 0.03968 0.04274 0.005323 0.08774 19 1280 0.8191 0.787 0.8148 0.4813 0.03756 0.03558 0.003467 37 /299 3.81 G 0.03944 0.04223 0.004929 0.0866 30 1280 0.7866 0.7923 0.8086 0.4805 0.03754 0.03538 0.003679 38 /299 3.81 G 0.03887 0.04134 0.004877 0.08508 17 1280 0.8304 0.7858 0.8189 0.4803 0.03796 0.0355 0.003923 39 /299 3.81 G 0.03951 0.04221 0.00479 0.08651 19 1280 0.8281 0.7721 0.8213 0.4862 0.03769 0.03535 0.003879 40 /299 3.81 G 0.03895 0.04139 0.004705 0.08505 14 1280 0.8253 0.7748 0.8202 0.4848 0.03746 0.03524 0.004167 41 /299 3.81 G 0.03802 0.04113 0.004671 0.08382 13 1280 0.8431 0.7325 0.7971 0.4835 0.03728 0.03565 0.004057 42 /299 3.81 G 0.03843 0.04141 0.00483 0.08467 17 1280 0.8652 0.7522 0.8104 0.4892 0.03699 0.03479 0.004673 43 /299 3.81 G 0.03834 0.04025 0.004736 0.08333 18 1280 0.8162 0.7747 0.8117 0.504 0.03673 0.03481 0.003932 44 /299 3.81 G 0.03769 0.04076 0.00451 0.08295 7 1280 0.7975 0.7835 0.809 0.4918 0.03679 0.03445 0.004368 45 /299 3.81 G 0.03813 0.04053 0.004463 0.08312 17 1280 0.8256 0.8027 0.8276 0.5009 0.03686 0.03439 0.003875 46 /299 3.81 G 0.0371 0.04001 0.004624 0.08173 29 1280 0.86 0.7688 0.8273 0.5112 0.03659 0.03426 0.004367 47 /299 3.81 G 0.03757 0.0406 0.00446 0.08263 14 1280 0.8553 0.7691 0.8276 0.5049 0.03598 0.03454 0.003633 48 /299 3.81 G 0.03728 0.03992 0.004224 0.08142 11 1280 0.8645 0.7723 0.8282 0.501 0.03647 0.03488 0.00427 49 /299 3.81 G 0.03628 0.04028 0.004376 0.08093 8 1280 0.8315 0.8041 0.8367 0.5126 0.03579 0.0346 0.003696 50 /299 3.81 G 0.03654 0.0391 0.004326 0.07997 9 1280 0.8226 0.7681 0.8215 0.5147 0.03585 0.03429 0.004232 51 /299 3.81 G 0.03596 0.03871 0.004178 0.07884 28 1280 0.8546 0.7444 0.8211 0.5092 0.03588 0.03475 0.004034 52 /299 3.81 G 0.03599 0.03876 0.004252 0.07899 22 1280 0.8101 0.804 0.8288 0.5189 0.0353 0.03431 0.00359 53 /299 3.81 G 0.036 0.03922 0.004096 0.07931 20 1280 0.8374 0.7999 0.8282 0.5131 0.03599 0.03425 0.00398 54 /299 3.81 G 0.03566 0.03897 0.004079 0.0787 19 1280 0.8623 0.7809 0.8351 0.5245 0.03553 0.03394 0.003699 55 /299 3.81 G 0.03523 0.03879 0.004144 0.07816 12 1280 0.8615 0.7836 0.844 0.5347 0.03534 0.03355 0.003704 56 /299 3.81 G 0.03565 0.03921 0.003934 0.07879 27 1280 0.8761 0.7676 0.8343 0.5232 0.03544 0.03381 0.003791 57 /299 3.81 G 0.03507 0.03821 0.003898 0.07717 8 1280 0.8419 0.7946 0.8268 0.5298 0.03492 0.03367 0.003683 58 /299 3.81 G 0.03484 0.0376 0.003726 0.07617 22 1280 0.8351 0.8041 0.8395 0.5347 0.03524 0.0337 0.003852 59 /299 3.81 G 0.03491 0.03849 0.003809 0.07721 13 1280 0.864 0.7756 0.8366 0.5307 0.03511 0.03348 0.00366 60 /299 3.81 G 0.03514 0.03793 0.004184 0.07725 14 1280 0.8825 0.7909 0.8415 0.5392 0.03449 0.03328 0.003941 61 /299 3.81 G 0.03426 0.03826 0.003802 0.07632 11 1280 0.8441 0.8113 0.8366 0.5401 0.03469 0.03365 0.00369 62 /299 3.81 G 0.0348 0.03766 0.003872 0.07633 17 1280 0.8773 0.7693 0.8334 0.5338 0.03487 0.03364 0.003922 63 /299 3.81 G 0.0338 0.03739 0.003659 0.07485 34 1280 0.8236 0.8167 0.8395 0.5399 0.03447 0.03365 0.003673 64 /299 3.81 G 0.03433 0.03751 0.003942 0.07578 13 1280 0.863 0.7942 0.8473 0.539 0.03422 0.03348 0.003743 65 /299 3.81 G 0.03378 0.03731 0.003611 0.07469 24 1280 0.8581 0.787 0.8399 0.5473 0.03417 0.03301 0.003658 66 /299 3.81 G 0.03389 0.03735 0.00346 0.0747 33 1280 0.8556 0.7905 0.838 0.5475 0.03419 0.03347 0.003729 67 /299 3.81 G 0.03354 0.03668 0.003535 0.07376 20 1280 0.9084 0.7523 0.8384 0.5439 0.03408 0.03354 0.003828 68 /299 3.81 G 0.03344 0.03656 0.003663 0.07367 17 1280 0.8523 0.794 0.8316 0.5478 0.03377 0.03341 0.003892 69 /299 3.81 G 0.03288 0.03575 0.003462 0.0721 19 1280 0.8646 0.7981 0.8357 0.5492 0.03386 0.03327 0.003735 70 /299 3.81 G 0.03359 0.03708 0.003678 0.07435 8 1280 0.8868 0.7892 0.8448 0.552 0.03418 0.03345 0.003514 71 /299 3.81 G 0.0334 0.03622 0.003542 0.07317 26 1280 0.8848 0.7989 0.8511 0.556 0.03414 0.0338 0.003917 72 /299 3.81 G 0.03259 0.03661 0.003493 0.07269 25 1280 0.8861 0.797 0.8485 0.5483 0.03377 0.03307 0.003898 73 /299 3.81 G 0.03337 0.03705 0.003538 0.07396 13 1280 0.8934 0.7701 0.8415 0.5584 0.03393 0.03352 0.003859 74 /299 3.81 G 0.03233 0.03589 0.003473 0.07169 17 1280 0.8575 0.8075 0.8495 0.5551 0.03376 0.03349 0.003457 75 /299 3.81 G 0.03244 0.03614 0.003586 0.07217 11 1280 0.8776 0.7943 0.84 0.5531 0.03376 0.03323 0.003653 76 /299 3.81 G 0.03265 0.03569 0.003482 0.07183 14 1280 0.914 0.7721 0.849 0.5648 0.0332 0.03322 0.003776 77 /299 3.81 G 0.03274 0.03632 0.003383 0.07244 6 1280 0.8792 0.8153 0.8542 0.5577 0.03356 0.03252 0.003789 78 /299 3.81 G 0.03198 0.03542 0.00331 0.07071 10 1280 0.8441 0.8086 0.844 0.555 0.03348 0.03283 0.003601 79 /299 3.81 G 0.03185 0.03493 0.00318 0.06996 8 1280 0.8391 0.8225 0.8512 0.5499 0.03369 0.03308 0.00373 80 /299 3.81 G 0.0322 0.03568 0.003317 0.0712 25 1280 0.9058 0.7779 0.8534 0.5619 0.03362 0.03303 0.003582 81 /299 3.81 G 0.03186 0.03547 0.003257 0.07059 19 1280 0.8525 0.8274 0.8565 0.5677 0.03346 0.03268 0.003568 82 /299 3.81 G 0.03156 0.03455 0.003246 0.06935 15 1280 0.8544 0.8248 0.8542 0.5638 0.03323 0.03307 0.003556 83 /299 3.81 G 0.03141 0.0348 0.003195 0.06941 9 1280 0.9053 0.7908 0.8566 0.5647 0.03334 0.03305 0.003336 84 /299 3.81 G 0.03125 0.03482 0.003035 0.0691 12 1280 0.8896 0.7795 0.8454 0.5641 0.03307 0.03318 0.003457 85 /299 3.81 G 0.03156 0.03436 0.003459 0.06938 26 1280 0.9084 0.7689 0.851 0.5672 0.03299 0.0328 0.0035 86 /299 3.81 G 0.03126 0.03485 0.00306 0.06918 23 1280 0.8864 0.7935 0.8456 0.561 0.03281 0.03252 0.003698 87 /299 3.81 G 0.031 0.03424 0.003094 0.06833 13 1280 0.9231 0.7873 0.861 0.5669 0.03258 0.03286 0.003801 88 /299 3.81 G 0.03123 0.03408 0.003101 0.06841 13 1280 0.8856 0.814 0.8598 0.5725 0.03235 0.033 0.003561 89 /299 3.81 G 0.03049 0.03394 0.003239 0.06768 8 1280 0.9137 0.7783 0.8533 0.5716 0.03283 0.03307 0.004051 90 /299 3.81 G 0.03116 0.03412 0.003089 0.06837 13 1280 0.8872 0.8078 0.8523 0.5643 0.03319 0.03313 0.003613 91 /299 3.81 G 0.03035 0.03456 0.003179 0.06809 27 1280 0.9366 0.7706 0.8525 0.5702 0.03281 0.03339 0.00342 92 /299 3.81 G 0.0304 0.03412 0.003072 0.06759 35 1280 0.9261 0.7864 0.8588 0.5613 0.03285 0.03383 0.003819 93 /299 3.81 G 0.03044 0.03372 0.003186 0.06736 16 1280 0.8934 0.8155 0.86 0.5809 0.03253 0.03289 0.003531 94 /299 3.81 G 0.02991 0.03364 0.002962 0.06652 12 1280 0.926 0.7973 0.858 0.5742 0.03262 0.0332 0.003725 95 /299 3.81 G 0.03023 0.03361 0.003202 0.06704 27 1280 0.9034 0.794 0.8466 0.5628 0.03283 0.033 0.003957 96 /299 3.81 G 0.03035 0.03462 0.003033 0.06801 21 1280 0.915 0.7857 0.8501 0.5747 0.03219 0.03329 0.003588 97 /299 3.81 G 0.03035 0.03334 0.00307 0.06676 27 1280 0.8977 0.8041 0.8579 0.5704 0.0326 0.03363 0.003257 98 /299 3.81 G 0.02993 0.03357 0.002958 0.06645 4 1280 0.9293 0.7993 0.8577 0.5795 0.03213 0.03308 0.003322 99 /299 3.81 G 0.02966 0.0334 0.002849 0.06591 25 1280 0.905 0.795 0.8508 0.5713 0.03244 0.03319 0.003794 100 /299 3.81 G 0.02944 0.03321 0.002964 0.06561 22 1280 0.886 0.8143 0.8536 0.5771 0.03199 0.03251 0.003453 101 /299 3.81 G 0.02967 0.03347 0.003052 0.06619 16 1280 0.9062 0.7976 0.8524 0.5731 0.03223 0.03295 0.003646 102 /299 3.81 G 0.02937 0.03372 0.002792 0.06588 21 1280 0.8968 0.8069 0.8593 0.5867 0.03199 0.03306 0.003499 103 /299 3.81 G 0.0298 0.03327 0.002872 0.06594 14 1280 0.8707 0.8163 0.8496 0.5721 0.03225 0.03285 0.003768 104 /299 3.81 G 0.02917 0.03281 0.002768 0.06475 28 1280 0.8949 0.8062 0.8548 0.5812 0.0317 0.03318 0.00345 105 /299 3.81 G 0.02891 0.03283 0.002961 0.0647 6 1280 0.8751 0.8164 0.8548 0.5823 0.03192 0.03326 0.003468 106 /299 3.81 G 0.02934 0.03341 0.00297 0.06571 26 1280 0.887 0.8042 0.8441 0.5785 0.03176 0.03306 0.003493 107 /299 3.81 G 0.02876 0.03214 0.002736 0.06364 27 1280 0.9033 0.7992 0.8555 0.5838 0.0319 0.03263 0.003525 108 /299 3.81 G 0.02846 0.03193 0.002688 0.06308 23 1280 0.901 0.8002 0.8552 0.5811 0.032 0.03264 0.003748 109 /299 3.81 G 0.02902 0.03268 0.002774 0.06447 13 1280 0.886 0.8208 0.8606 0.5804 0.03181 0.03261 0.003785 110 /299 3.81 G 0.02885 0.03254 0.002836 0.06422 9 1280 0.8682 0.8291 0.8586 0.5758 0.03168 0.0326 0.00353 111 /299 3.81 G 0.02856 0.03203 0.002739 0.06333 15 1280 0.9028 0.793 0.8553 0.5877 0.03188 0.03295 0.003094 112 /299 3.81 G 0.0281 0.03246 0.002664 0.06322 15 1280 0.8805 0.8068 0.8552 0.5878 0.03163 0.0334 0.003304 113 /299 3.81 G 0.02848 0.03189 0.0027 0.06307 23 1280 0.8952 0.8148 0.8554 0.5849 0.03196 0.03312 0.003647 114 /299 3.81 G 0.02881 0.0316 0.002701 0.06311 22 1280 0.8875 0.8247 0.8587 0.5891 0.03149 0.03333 0.003354 115 /299 3.81 G 0.02839 0.03147 0.002545 0.0624 10 1280 0.8964 0.8158 0.855 0.5848 0.03168 0.03336 0.003575
继续
用2080TI跑了一天,100多个epoch,map到0.855的样子。作为baseline或者init_weight暂时够了,今天的任务是提交一次可运行结果。
检测结果
提交说明
1 2 3 4 5 6 [{ "image_id" : int, "category_id" : int, "bbox" : [xmin,ymin,xmax,ymax], "score" : float }]
选手提示:
image_id:为A榜测试数据中image在csv当中的序列号,从0开始,为0、1、2、3……的int类型数字,其最大值小于599,超出则会报错;
因为存在同一个框多个识别结果的情况,提交结果的条数不设限,可以超过600条。
category_id:为需要检测的结果类别,同样为int,具体数字见下方描述,category_id每次只提交1个类别,若一个框满足多个识别结果,需要分block来写。
选手需要提交的测试结果为以下几类,且图像的category_id应与下方的注释保持相同:
guarder(监护人员)
gloveperson(规佩戴绝缘手人员)
wronggloveperson(不合规佩戴绝缘手套人员)
operator(有手持工具人员)
转换规则有些麻烦,稍后得结合alphapose之类的修正一下,先用中心点的距离试试看
中心点距离最后是不能用的,因为有情况3 情况3: 手套没有戴在手上,手拿手套,为不合规 ,最后应该是需要用到姿态检测
第一次提交,简化一下流程。
提交
应该是id超出了,重新生成一下
91名
修改
接下来有两个方向。
一个是改进yolov5的精度。
还一个是改变最后的转换规则。
yolo部分增大分辨率,提高一下精度。
转换这边应该是不能用其他模型。重新捋一下。
转换规则
写错了一个地方,没有检测袖章部分
修改一下
79名
还有个逻辑错误,检测出错误的是不合规,剩下的算合规。
还是应该判断一下。
重新梳理一下转换规则。
识别出所有在场人员,并具体区分出监护人员(佩戴红色袖章);
识别出在场的合规佩戴绝缘手套(到小臂处的橡胶材质)人员,以及不合规佩戴绝缘手套(佩戴其他材质手套、赤裸手掌、半裸手掌、手部皮肤有裸露等,均属于不合规)人员;
识别出现场人员是否有手持工具(操作杆或绝缘笔);
其中有几种特殊情况需要注意:
-情况1:两只手都可以观察到,但是只佩戴了1只手套,为不合规佩戴。
-情况2:两只手只能看到一只手,也只佩戴了一只手套,为合规佩戴。
-情况3: 手套没有戴在手上,手拿手套,为不合规
识别出所有在场人员,并具体区分出监护人员(佩戴红色袖章);
根据数据集来看,监护人员有0个或1个,求袖章与人物的IOU面积应该是可以比较准确的判断的。
因为袖章一般是戴在胳膊上的,所以IOU应该比中心点距离强一些。
更新模型
然后更新了一下检测权重(分辨率从640调整到1280)
中心点
IOU
虽然一直在进步,而且还有不少地方有明显的空间。但是怎么也不觉得能达到0.97以上。感觉应该是方法不对。
明天开始要做简历,换个方法做没什么时间了,改进一下目标到0.8以上,然后等优胜方案。
非常简单的修改
最开始用手套和每个人的中心点去计算距离,然后换成了iou
现在写了个方法,对手套或者道具进行判断,是否重叠,或者说属于
然后对符合标准的进行计数
再按照规则进行最后的筛选。
比如如果有badge就认为这个人是监督
如果有两个正确的手套,就认为是对的
等等
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def is_overlap (rec1, rec2, thres ): left_up_x = max(rec1[0 ], rec2[0 ]) left_up_y = max(rec1[1 ], rec2[1 ]) right_bottom_x = min(rec1[2 ], rec2[2 ]) right_bottom_y = min(rec1[3 ], rec2[3 ]) if right_bottom_x < left_up_x or right_bottom_y < left_up_y: return 0 intersect = (right_bottom_x - left_up_x) * (right_bottom_y - left_up_y) area_rec1 = (rec1[2 ] - rec1[0 ]) * (rec1[3 ] - rec1[1 ]) area_rec2 = (rec2[2 ] - rec2[0 ]) * (rec2[3 ] - rec2[1 ]) if intersect / area_rec2 > thres: return 1 else : return 0
直接把结果刷过了0.86,差不多就这样吧
总结
最终成绩 B榜 score:0.8656 23名
时间很少,大概就做了3,4天,训练期间还在干别的
用的方法就是原版的yolov5进行检测
然后通过iou和阈值,把检测出来的物体进行组合
然后通过类似词袋的方法获取最终结果
如果只做到这里应该是没什么意义的,除了等优胜方案出来,接下来要把使用到的技术搞明白
TODO
Yolo系列的全架构
v1到v5的变更,及v5所使用到的所有tricks总结