File size: 30,163 Bytes
1a58e9e
8ce8f10
1a58e9e
 
 
 
 
02af94d
f5824b7
1a58e9e
 
 
 
 
fd5d5e3
1a58e9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce460b4
 
08eae23
ccbb876
1a58e9e
f5824b7
 
 
 
ccbb876
e2e7a2c
 
1a58e9e
 
 
708b8d0
1a58e9e
159ae8f
1a58e9e
 
 
 
 
 
 
 
 
 
8ce8f10
 
1e9e587
b1f58c4
1a58e9e
02af94d
 
1a58e9e
 
 
 
 
02af94d
1a58e9e
 
 
 
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
import numpy as np
img_vec = np.array([[0.001183745, 0.0006474623, 0.9962907, 1.0715525e-05, 0.00025993327, 0.0016074692], [1.0901107e-06, 0.9997192, 0.00015559935, 6.622048e-05, 4.5755154e-05, 1.2046643e-05], [6.780453e-05, 0.9600331, 0.00020796066, 0.00074749015, 0.0033559885, 0.03558765], [9.2790346e-05, 6.0882794e-06, 1.5991038e-05, 1.153297e-05, 0.9985512, 0.0013223367], [0.00064366346, 0.0011190572, 0.9874978, 4.3241245e-05, 0.00935937, 0.0013369184], [5.2049214e-05, 1.2801657e-06, 2.9498646e-05, 1.7153299e-06, 2.559748e-05, 0.99988985], [0.0011970395, 9.731338e-06, 2.1237669e-05, 2.5094421e-05, 0.9977976, 0.000949231], [3.6162317e-06, 0.99877614, 2.023129e-05, 4.7237274e-05, 0.0011406511, 1.2184895e-05], [1.0230211e-05, 1.4835642e-06, 1.3025513e-05, 2.512241e-06, 0.003777029, 0.9961958], [0.0008493654, 1.1132153e-05, 0.00043108794, 1.4500493e-05, 0.00025561644, 0.9984382], [0.0019356995, 0.00017562874, 2.8180919e-05, 0.9975648, 4.8310343e-05, 0.00024738634], [0.0011779362, 0.00065545057, 0.99803513, 1.6797849e-06, 0.00010095722, 2.8904156e-05], [9.089741e-05, 0.978512, 0.005697065, 0.0005912572, 0.0011946606, 0.0139141055], [0.0005574316, 1.5321544e-05, 0.998833, 1.0735541e-06, 1.3806449e-05, 0.00057943986], [3.3686506e-06, 0.9970419, 0.0023412593, 5.4328397e-05, 0.0005123902, 4.668524e-05], [0.00033546498, 7.646274e-06, 0.00027485247, 3.023207e-06, 0.00021423706, 0.9991648], [1.8367424e-05, 4.2896054e-06, 0.000106551015, 4.9463824e-06, 0.0002757381, 0.9995901], [0.9992767, 1.0295089e-05, 0.0005470521, 6.5369866e-05, 2.390274e-05, 7.664138e-05], [0.9813146, 2.0880283e-05, 0.00026747925, 5.134113e-05, 0.00017709624, 0.018168535], [0.000114715054, 3.5882879e-06, 6.4218184e-05, 9.025374e-07, 2.9348028e-05, 0.99978715], [8.362681e-05, 3.8040469e-06, 3.1611694e-06, 5.5942483e-06, 2.07715e-05, 0.99988306], [2.381162e-05, 5.388778e-06, 0.9998869, 3.7252593e-07, 5.261669e-06, 7.830333e-05], [2.0016892e-06, 5.1701e-05, 3.349846e-06, 3.764534e-06, 3.08445e-07, 0.99993885], [2.2664715e-05, 0.99886394, 0.00025650975, 0.0006828798, 6.1300234e-05, 0.00011275579], [0.00468414, 0.00089653797, 0.8993314, 0.0002791324, 0.047310602, 0.047498215], [0.00071968854, 0.00012177682, 0.24034318, 0.00021860476, 0.0041009136, 0.75449586], [0.0011865953, 9.121098e-05, 0.9970276, 5.668214e-06, 0.00016106537, 0.001527927], [2.3530924e-06, 2.1742053e-06, 5.649086e-07, 4.312148e-07, 3.4217187e-06, 0.99999106], [0.00014497749, 0.0025425302, 4.2945932e-05, 0.00046326726, 6.245927e-05, 0.9967438], [0.00011293146, 0.00020251136, 0.99934644, 1.5175293e-05, 1.2938454e-05, 0.0003099968], [2.1264614e-05, 8.0309466e-05, 4.3275886e-05, 5.127402e-06, 0.00022328363, 0.99962676], [0.20738572, 0.0003576652, 0.01344411, 0.009969251, 0.74644786, 0.022395454], [0.00020409816, 3.12241e-05, 6.8546e-05, 2.2159917e-05, 0.0001425006, 0.9995315], [0.00014553087, 0.00028567325, 0.00020951268, 1.4521221e-05, 2.8495773e-05, 0.9993162], [0.0008911211, 8.1792154e-05, 0.99874395, 3.3982797e-06, 0.00012417257, 0.000155491], [0.00038905922, 9.907559e-06, 0.00018059136, 3.0968743e-06, 0.0011700838, 0.99824727], [1.7221013e-05, 2.6349528e-06, 5.5370288e-06, 2.477567e-06, 8.265479e-05, 0.9998895], [9.9847566e-05, 6.3684242e-06, 0.9982102, 2.084257e-06, 0.00013659797, 0.0015449121], [1.0410963e-05, 6.426374e-05, 1.8598449e-06, 6.239615e-06, 7.999239e-05, 0.9998373], [0.0869675, 0.06584302, 0.6744239, 0.10300095, 0.01296012, 0.056804616], [0.0117717115, 0.00048132922, 0.97692513, 0.00019082078, 0.0019260441, 0.008704997], [0.00024866726, 3.399789e-06, 1.9388704e-05, 5.750063e-06, 7.2076978e-06, 0.9997155], [2.4895007e-07, 0.99995446, 2.479923e-05, 1.8267598e-06, 2.6911289e-06, 1.5947582e-05], [0.9994961, 4.9302357e-06, 7.520917e-06, 1.349918e-05, 3.1691372e-05, 0.00044620666], [0.0110280635, 5.7762674e-05, 0.94336766, 8.401646e-05, 3.855721e-05, 0.04542392], [6.528507e-05, 8.321988e-06, 0.0003266337, 2.215188e-05, 3.3083543e-05, 0.99954444], [9.423565e-05, 4.435012e-05, 3.656979e-05, 8.248457e-05, 0.0001624587, 0.99957997], [0.0010561227, 2.2123982e-05, 0.0007157712, 7.461979e-06, 3.649775e-05, 0.998162], [0.00010612672, 1.2822995e-05, 0.0002027852, 0.00014030428, 1.5221644e-05, 0.9995227], [2.5843387e-05, 5.8845282e-05, 3.468311e-05, 3.2176097e-06, 0.00012839773, 0.999749], [6.324824e-05, 0.9942643, 0.00085196213, 0.00046436148, 0.00011373451, 0.004242372], [0.00014700319, 8.9749e-06, 0.9986589, 1.4744371e-05, 0.00020180215, 0.00096853205], [0.00014962514, 2.0305952e-05, 0.00014865371, 1.0956987e-05, 5.2481402e-05, 0.99961793], [0.9980076, 2.7990957e-06, 6.032486e-05, 0.00044359695, 0.00019174292, 0.0012939703], [0.007691547, 0.00093500345, 0.18037315, 0.00011863655, 0.020382222, 0.79049945], [0.21641138, 1.0207995e-05, 0.7222835, 3.0492043e-05, 4.4889697e-05, 0.061219506], [6.379888e-07, 1.6201967e-06, 3.1150805e-06, 3.8368708e-07, 6.1940234e-05, 0.9999323], [3.700095e-07, 5.901578e-06, 2.6105167e-07, 1.0030352e-06, 1.633056e-05, 0.99997616], [5.0621533e-05, 1.9467757e-06, 0.00022180694, 2.1919059e-06, 7.0791066e-05, 0.99965274], [2.1096278e-06, 4.6794298e-07, 4.203205e-06, 2.0262368e-07, 3.1075838e-06, 0.99998987], [0.00025825168, 0.98656857, 6.320665e-05, 0.0012662264, 0.0023025833, 0.00954124], [0.00044160953, 1.6045897e-05, 4.3325945e-05, 1.8907632e-06, 5.028731e-05, 0.9994468], [0.00019488716, 0.00019058606, 8.41964e-05, 6.888353e-05, 0.0001687472, 0.99929273], [4.5704277e-05, 6.786345e-05, 0.9982115, 2.6210228e-06, 0.0006911959, 0.0009810921], [7.6331664e-05, 2.011664e-06, 2.8380348e-06, 7.573107e-07, 0.00012957981, 0.9997886], [0.0004087675, 4.0216288e-05, 9.504767e-05, 4.42647e-06, 0.00020630336, 0.9992453], [0.00023382794, 4.4813132e-05, 7.9612044e-05, 6.986424e-05, 0.00073117134, 0.99884075], [0.062337544, 3.3703975e-05, 0.9317716, 2.508398e-05, 0.0012973467, 0.0045347577], [1.353101e-05, 7.160427e-06, 8.9427135e-07, 1.0162887e-05, 1.2177648e-05, 0.99995613], [0.9647493, 8.234284e-06, 0.0012121877, 0.00016015388, 4.2248827e-05, 0.033827987], [9.6978925e-05, 7.325615e-06, 0.99978405, 4.1737053e-07, 6.712808e-05, 4.4136286e-05], [0.00039633378, 3.7775088e-05, 0.9984524, 2.0990623e-05, 0.0004990453, 0.00059333554], [3.810157e-05, 3.0353576e-06, 1.0080317e-05, 9.042036e-07, 6.2223257e-06, 0.9999417], [0.4111154, 0.0011122819, 0.4517259, 0.00014106455, 0.13472192, 0.0011834597], [5.320623e-06, 4.627046e-07, 0.99999225, 1.3624614e-07, 1.2822727e-06, 6.382401e-07], [0.9999937, 6.208606e-08, 1.581343e-07, 4.891238e-06, 6.107547e-07, 5.9826743e-07], [2.8962797e-05, 3.721352e-05, 8.860266e-05, 0.00039464454, 6.6442367e-06, 0.99944395], [0.0032606511, 0.011139718, 0.030814923, 0.00024155801, 0.06561669, 0.8889264], [2.5870377e-06, 2.7707129e-06, 2.0302086e-05, 1.6544083e-06, 1.1963882e-05, 0.9999608], [0.000202565, 2.6852873e-05, 0.0003634819, 0.00024846158, 0.0007974159, 0.9983612], [2.0926058e-05, 1.8182202e-06, 1.1790693e-07, 4.8341514e-07, 6.0446206e-07, 0.99997604], [0.028095853, 4.3367876e-05, 0.0016105362, 2.8183706e-05, 0.0017630305, 0.968459], [1.9018269e-05, 6.0379352e-06, 4.9211743e-05, 1.0085847e-05, 0.00012530744, 0.99979025], [0.060545366, 0.0004554764, 0.00046816227, 0.002502421, 0.00044651356, 0.93558204], [0.27325073, 0.00771274, 0.019479744, 0.0021354912, 0.005549205, 0.6918721], [0.9551394, 4.7516158e-05, 0.0074541913, 0.0037016356, 0.028489739, 0.0051675453], [0.99861693, 1.0142513e-05, 0.00060740334, 0.0002856261, 0.00034672575, 0.00013314377], [0.9792437, 2.468583e-05, 0.00081091846, 0.00016031889, 0.013843318, 0.005916974], [1.6959195e-06, 5.918661e-05, 0.9998678, 5.2934445e-07, 6.7718014e-05, 3.1154234e-06], [0.00012123352, 4.2831598e-05, 1.216062e-05, 4.2108844e-05, 6.7003886e-05, 0.9997147], [0.01510195, 0.011391317, 0.96790373, 0.0018710705, 0.003040597, 0.00069139147], [0.047799855, 0.0008591413, 0.91728127, 0.00034789066, 0.01108827, 0.022623597], [6.4263186e-05, 0.9823163, 0.0018647922, 0.0005431149, 0.002682755, 0.012528814], [1.060747e-05, 1.8184604e-05, 1.4086738e-05, 3.2358553e-06, 0.0010587095, 0.9988952], [3.5722267e-05, 2.5053894e-05, 0.9998696, 4.995491e-06, 1.1931344e-05, 5.2669675e-05], [0.0001805724, 0.0001780914, 9.717351e-05, 2.4770374e-05, 0.00036272118, 0.9991567], [0.000122015765, 0.037958253, 0.95994574, 4.104272e-05, 0.0018042325, 0.00012869414], [0.0030229634, 0.0020233607, 0.09346539, 0.0017162731, 0.8942453, 0.005526651], [0.9937542, 3.3676264e-05, 2.9989189e-05, 0.00026614027, 0.0015670614, 0.004348961], [1.9596002e-05, 5.460919e-07, 2.370617e-05, 4.5871317e-07, 2.7834278e-05, 0.99992776], [0.9841687, 8.3942214e-05, 0.0048708566, 0.00049588655, 0.0062702587, 0.004110364], [0.0012712743, 0.010262053, 0.7756221, 0.00039430457, 0.015086965, 0.19736323], [3.714552e-05, 1.3856393e-07, 5.570143e-07, 1.12131616e-07, 3.007406e-06, 0.999959], [0.0013944668, 0.26817438, 0.00019180149, 0.2411945, 0.0015136658, 0.4875312], [0.97960424, 0.00090531213, 0.003989057, 6.44968e-05, 0.014767058, 0.00066983316], [9.791337e-05, 0.0020514317, 0.9841254, 8.117802e-06, 0.008534896, 0.0051823542], [6.738693e-05, 0.99966264, 3.6401958e-05, 1.3951828e-05, 8.889249e-05, 0.00013071796], [4.5688095e-05, 0.9969543, 0.00018425529, 0.002266784, 0.0004785581, 7.049832e-05], [2.6118161e-05, 2.821403e-05, 0.00042664632, 2.667754e-06, 0.00010307418, 0.9994134], [0.55532414, 0.06486542, 0.13558346, 0.14332081, 0.09034258, 0.010563576], [0.02537992, 0.012770072, 0.011560863, 0.002702126, 0.01272034, 0.93486667], [1.4797672e-05, 3.2593474e-05, 2.8730577e-07, 6.1165274e-06, 8.588703e-05, 0.9998604], [1.4056281e-05, 0.9992576, 0.0001368214, 0.0001096892, 0.000101724356, 0.00037998933], [3.2113876e-05, 4.381272e-06, 1.3588096e-05, 5.2938367e-06, 0.00019010111, 0.9997545], [3.980216e-05, 0.9927362, 1.9653033e-05, 0.0026291257, 0.00011515237, 0.0044601825], [3.3344858e-07, 0.9999144, 7.431238e-06, 2.9017136e-05, 2.0104364e-06, 4.687988e-05], [2.0299e-05, 0.00026857707, 0.99965525, 8.63277e-06, 3.0682426e-05, 1.6589112e-05], [3.8010163e-05, 0.0001383517, 0.995133, 1.521408e-05, 4.657542e-05, 0.004628879], [0.12308153, 2.489043e-05, 0.8752798, 2.9667186e-05, 0.0010696792, 0.000514401], [0.00032874738, 0.00021865449, 0.0029459381, 1.4962456e-05, 0.00019187776, 0.9962998], [0.00022268503, 4.6128192e-05, 2.0412494e-05, 6.159439e-05, 0.00018424918, 0.9994649], [0.0009106945, 4.6750333e-06, 0.00016835274, 3.4454362e-05, 5.437541e-06, 0.9988764], [0.0009086432, 6.905265e-06, 5.2536823e-05, 9.51128e-06, 0.0005336625, 0.99848866], [0.000131248, 4.7636545e-06, 7.685613e-05, 1.7842296e-05, 0.00047826278, 0.99929094], [0.00026619728, 0.00035798625, 3.050228e-05, 1.1484066e-05, 6.626383e-05, 0.99926764], [0.99492633, 5.282282e-06, 9.946715e-06, 1.2689495e-05, 0.0019318591, 0.0031139087], [1.4393011e-08, 0.99996495, 6.941955e-07, 8.697407e-06, 1.967679e-07, 2.5424346e-05], [6.1357e-05, 3.1514207e-06, 4.1484117e-07, 5.09586e-05, 0.0020736544, 0.99781054], [2.7012084e-07, 0.9994842, 1.6615793e-06, 0.00040997102, 9.671086e-05, 7.160311e-06], [6.289912e-07, 0.9984425, 7.5222724e-06, 0.0015347947, 7.0304645e-06, 7.4890313e-06], [0.00012157771, 0.9783458, 0.0076096044, 0.0012147872, 0.00075894385, 0.01194926], [0.00015882205, 0.92775184, 0.010058753, 0.053803004, 0.0038493501, 0.0043781577], [9.904012e-06, 4.165955e-06, 0.9998274, 1.493186e-06, 4.233632e-05, 0.00011471924], [4.3504988e-05, 1.6005041e-06, 9.248142e-05, 6.269679e-07, 0.9998579, 3.8030407e-06], [0.004050395, 0.0015096538, 0.6600044, 0.0014810426, 0.1195238, 0.21343073], [4.9294234e-05, 1.4401965e-06, 3.9180737e-05, 3.6835079e-06, 7.204228e-05, 0.9998343], [8.1702434e-05, 0.99129593, 0.00015590455, 0.006926346, 0.0005970032, 0.0009430413], [0.92345876, 7.240447e-05, 0.017646626, 4.7569676e-05, 0.04237895, 0.016395692], [0.5676307, 3.345717e-05, 6.1482565e-06, 0.0002506989, 0.40780723, 0.024271764], [3.74945e-05, 0.0002236717, 0.0032615438, 2.8050257e-05, 0.00028378324, 0.9961654], [0.80141723, 0.0007757123, 0.024232844, 0.0082962215, 0.07346507, 0.09181299], [0.093815535, 0.009962727, 0.16484103, 0.00034277193, 0.110787295, 0.62025064], [0.9914249, 3.3285618e-05, 1.4177965e-05, 5.4501095e-05, 0.008352657, 0.00012050959], [0.89826256, 0.0075039687, 0.00097294664, 0.00014346637, 0.0022207785, 0.09089628], [1.5040547e-05, 0.00027596884, 0.00011564757, 1.6139877e-05, 0.00031098162, 0.9992662], [0.0007767057, 0.00042791798, 0.98860514, 1.1928862e-05, 0.009887692, 0.0002906403], [0.4673994, 0.00046199118, 0.018478498, 0.026310703, 0.0025114396, 0.48483795], [0.00024174964, 0.999311, 1.3026157e-05, 0.00036510662, 3.04754e-05, 3.8625643e-05], [0.00049108005, 8.291264e-05, 1.904993e-05, 3.540895e-06, 1.7177284e-05, 0.9993862], [0.96055233, 2.258286e-05, 0.03799276, 0.00010049599, 0.0005647978, 0.0007671073], [8.2665576e-07, 0.9998913, 4.5214394e-05, 4.160851e-05, 2.4786823e-06, 1.8634972e-05], [7.672811e-05, 0.11272975, 0.0007890531, 0.885402, 0.0008227498, 0.00017966662], [0.00071230385, 0.5516768, 8.690722e-05, 0.44231993, 0.0030954983, 0.0021085672], [0.0016641148, 0.77376026, 0.0031669345, 0.0009105488, 0.21182135, 0.008676735], [6.535834e-06, 8.022754e-06, 1.4224903e-06, 1.215236e-06, 1.1371254e-06, 0.99998176], [6.131489e-06, 0.9909105, 0.00059569377, 5.8810587e-05, 0.008347422, 8.145085e-05], [0.0036011222, 0.019580165, 8.709692e-06, 0.97638834, 0.00014254787, 0.00027917026], [0.0086707845, 0.00019842519, 7.946216e-06, 0.990886, 7.297908e-05, 0.00016386487], [2.1503301e-05, 0.00016361932, 1.08347315e-07, 0.9998073, 2.8828802e-06, 4.5499937e-06], [0.00020062785, 0.00021684812, 4.28962e-07, 0.99948347, 6.681421e-05, 3.179363e-05], [9.77566e-05, 0.0063463016, 2.1972079e-05, 0.9933281, 1.2384863e-05, 0.00019351323], [0.00022732468, 0.028287608, 5.508699e-06, 0.97141, 7.669675e-06, 6.191368e-05], [0.00010191731, 0.0019176323, 6.4018345e-06, 0.9976427, 7.411093e-05, 0.00025718144], [9.5899224e-05, 0.00012591598, 2.5450026e-07, 0.999546, 4.338007e-07, 0.00023143641], [0.00084430055, 0.0003077784, 7.928243e-05, 0.99862146, 2.9028893e-06, 0.00014420082], [3.070976e-05, 1.4407342e-05, 4.922463e-06, 0.9999467, 5.0399626e-07, 2.8007819e-06], [2.182484e-06, 2.3648156e-06, 3.133209e-08, 0.999951, 8.8792e-06, 3.557294e-05], [2.3768967e-05, 0.00420844, 6.2199438e-06, 0.9949956, 0.00056535157, 0.00020066672], [9.024704e-05, 0.00071282196, 2.027537e-05, 0.9991554, 1.3690523e-05, 7.5391968e-06], [2.1495691e-06, 0.0004972608, 3.113801e-08, 0.9994978, 4.523372e-07, 2.2732054e-06], [0.0003065313, 0.00059253303, 1.6592052e-05, 0.9990299, 5.0043127e-06, 4.949302e-05], [1.6929504e-05, 0.00011503535, 1.5254145e-06, 0.9998354, 2.6390417e-05, 4.722362e-06], [5.6169597e-06, 0.00011384774, 2.1649846e-07, 0.9998567, 9.4081577e-07, 2.2666374e-05], [5.695287e-07, 0.00030449417, 8.784171e-07, 0.9996848, 5.7088266e-07, 8.743865e-06], [0.96802396, 0.0011401338, 0.0006414005, 0.012876046, 0.016900558, 0.00041794247], [0.99708563, 7.2331336e-06, 0.00010419245, 0.0017417073, 0.00017315094, 0.00088801904], [0.1836484, 4.0118433e-05, 4.081512e-05, 0.8140678, 0.0006166435, 0.0015862678], [0.99991655, 4.864144e-07, 1.1551377e-06, 7.4648844e-05, 1.2844619e-06, 5.8139094e-06], [0.001647608, 0.076293394, 1.2701269e-05, 0.92194176, 1.301484e-05, 9.15832e-05], [0.9046488, 0.00023455628, 0.0006606251, 0.0006845926, 0.04589403, 0.047877423], [0.00050204765, 2.0403615e-05, 7.9007244e-05, 2.1124499e-05, 5.3936452e-05, 0.9993236], [0.0031150877, 8.02112e-05, 0.00015845039, 6.3938845e-05, 0.0016357077, 0.99494666], [0.0007772997, 0.0007210602, 0.01764605, 7.361244e-05, 0.9794064, 0.0013755969], [1.092967e-05, 2.6199616e-05, 0.9994535, 5.5161695e-07, 4.1998333e-06, 0.0005045896], [0.00074107497, 6.249547e-05, 1.5016968e-06, 0.9991208, 2.1123944e-06, 7.207935e-05], [8.246728e-05, 2.4306062e-05, 2.6191383e-06, 5.0426148e-05, 0.00029047733, 0.9995497], [0.0012737855, 0.99381834, 0.000585406, 0.0015706997, 0.0014001757, 0.0013514818], [8.685351e-05, 5.156524e-06, 4.2824364e-08, 0.9998448, 4.6887053e-06, 5.849332e-05], [2.5920344e-05, 5.9470875e-07, 0.00010270729, 5.263072e-07, 4.197646e-06, 0.9998661], [0.0005088439, 0.6050116, 0.000126596, 0.070065804, 0.0987508, 0.22553635], [6.2120955e-07, 2.2758265e-07, 5.480935e-06, 1.8060189e-07, 0.99999344, 7.717837e-08], [2.9583014e-06, 2.6741093e-06, 0.9999702, 1.764473e-07, 2.3263062e-06, 2.1712807e-05], [2.0919259e-05, 1.2906702e-05, 6.5552235e-06, 1.3385505e-05, 0.99959487, 0.00035131985], [7.440152e-05, 0.0004271677, 2.4631821e-05, 2.0266934e-05, 0.00013450153, 0.9993191], [0.0012294265, 0.0018165717, 9.921876e-05, 0.9802844, 0.0010831491, 0.015487337], [0.0035964532, 0.29794478, 0.00022725535, 0.00025646458, 0.6232994, 0.074675746], [1.234367e-07, 5.1026674e-08, 6.8976306e-08, 2.9441651e-08, 0.99999917, 5.258564e-07], [0.16276558, 0.0010845277, 0.041348994, 0.0032539757, 0.066908576, 0.7246383], [0.08541294, 0.019558622, 0.0069591375, 0.79469335, 0.0643019, 0.029074077], [6.185024e-05, 0.9930807, 9.761023e-05, 0.0011595881, 0.00013113415, 0.005469082], [3.8077026e-06, 9.971062e-07, 3.7349713e-07, 6.191587e-07, 0.9998841, 0.00011005292], [0.0011424677, 0.9948421, 0.00018230797, 0.0036412475, 9.0970265e-05, 0.00010094595], [2.2511651e-06, 0.99963295, 1.8333226e-07, 3.998104e-06, 7.165079e-06, 0.00035331433], [4.3774642e-05, 6.518069e-05, 1.2544648e-05, 2.9376588e-06, 3.7421338e-05, 0.9998381], [5.46777e-06, 0.00012650232, 5.231328e-06, 7.169644e-05, 6.6258435e-05, 0.9997248], [9.9661e-05, 0.89835864, 0.00027907014, 0.08072742, 0.00031119332, 0.020223973], [9.006079e-06, 2.0945563e-06, 0.00039450964, 2.0645568e-06, 0.00015072287, 0.99944156], [2.5607067e-06, 0.999889, 2.4272597e-06, 4.6501813e-05, 1.0351929e-05, 4.914555e-05], [2.3505838e-06, 2.4279557e-06, 0.00022012561, 5.8173043e-07, 0.99977416, 2.6799043e-07], [1.0489936e-05, 6.107882e-06, 0.00026682855, 1.3795212e-06, 0.99966, 5.5142635e-05], [0.9829352, 1.7330653e-05, 1.8562496e-05, 0.0018493875, 8.8764034e-05, 0.0150907645], [4.4232813e-05, 5.063686e-05, 0.0015342154, 9.367001e-06, 0.00029531983, 0.9980661], [0.11891294, 0.00039731004, 0.0003084687, 0.8454067, 0.0022102597, 0.03276432], [4.9985432e-05, 2.7740805e-05, 0.0003187673, 2.1010821e-06, 0.99959296, 8.490503e-06], [2.1748872e-05, 8.499661e-05, 0.0010120998, 1.1230745e-05, 3.278015e-05, 0.9988372], [1.034234e-05, 6.0056624e-07, 6.9748644e-06, 3.5260314e-07, 1.144546e-05, 0.9999703], [0.0001877031, 3.1890877e-06, 0.000101319085, 6.993333e-07, 7.763145e-05, 0.9996294], [8.3836916e-05, 0.005547924, 0.00039862393, 0.000108920045, 0.99143815, 0.002422575], [0.0006285895, 4.1265416e-06, 0.00011839394, 3.9118786e-06, 0.00019864387, 0.99904627], [2.5511328e-05, 2.2382694e-05, 0.00068910583, 2.799832e-06, 0.99924445, 1.5777445e-05], [2.4022338e-06, 4.5362372e-05, 7.421631e-05, 4.7265025e-06, 0.9992071, 0.0006663251], [1.3185683e-05, 0.9982198, 1.3063982e-05, 1.681225e-05, 0.00072716037, 0.0010100799], [5.165657e-05, 0.000688231, 6.000221e-05, 1.5558158e-05, 0.0002697674, 0.9989147], [1.0735659e-05, 1.3671194e-05, 4.227441e-05, 4.4903776e-05, 0.9993761, 0.00051230664], [0.00030333333, 1.0760356e-05, 0.00044995217, 1.1762204e-05, 0.000112493086, 0.9991117], [0.00085163803, 0.2717793, 0.0019585348, 0.7247828, 0.00018457211, 0.00044315032], [4.500704e-06, 0.0009317161, 2.6960635e-05, 3.3543074e-05, 0.0009174851, 0.99808574], [0.0018399747, 1.3687443e-05, 0.001048699, 1.3275439e-05, 0.000117915246, 0.9969664], [2.710813e-06, 4.9781727e-05, 0.00041878622, 1.1818678e-06, 0.99946433, 6.313691e-05], [4.578696e-06, 0.00029632653, 0.00028097918, 3.6440688e-06, 0.9993286, 8.5833e-05], [0.0002236624, 0.00011211113, 0.0030080564, 5.496472e-05, 0.99636155, 0.00023955254], [0.9988569, 1.3130588e-06, 1.3194274e-05, 0.0002828806, 4.7051103e-06, 0.00084089715], [4.3632892e-05, 5.206154e-06, 0.00016597346, 1.3473397e-06, 6.481596e-05, 0.99971896], [0.00046200247, 9.830523e-05, 4.2297e-05, 2.5810261e-05, 0.9979887, 0.0013829027], [1.7584594e-05, 0.002560501, 0.0020415622, 8.067711e-05, 0.9947314, 0.00056826003], [3.763388e-05, 3.1423453e-05, 0.00087923533, 6.4798787e-06, 0.99874675, 0.00029847337], [2.7089547e-05, 7.297227e-05, 0.0004936406, 3.937767e-05, 0.9990025, 0.0003645332], [0.61067986, 6.9784524e-05, 0.05870003, 0.00018060916, 0.2250152, 0.105354525], [0.00014123062, 5.6824324e-06, 5.542289e-06, 9.610236e-07, 0.99950194, 0.00034456333], [9.863403e-05, 1.9847114e-06, 0.00015968681, 6.363177e-06, 0.00011267573, 0.9996207], [2.675927e-05, 4.407459e-05, 0.02329846, 1.5754497e-06, 0.97655153, 7.768836e-05], [0.9416691, 7.182365e-05, 0.0048196693, 0.0003993022, 0.052428376, 0.000611698], [1.0464636e-08, 0.9999895, 2.9537887e-06, 1.0882072e-06, 3.3593801e-06, 3.0936965e-06], [1.2024945e-05, 3.3169403e-05, 1.232853e-05, 5.4537804e-06, 0.00011611515, 0.9998209], [0.00013054383, 0.0015564283, 0.019155724, 3.1463827e-05, 0.979001, 0.00012479375], [0.0001429185, 7.4907725e-06, 1.1761779e-05, 2.393818e-06, 0.9998276, 7.804146e-06], [3.4312263e-05, 0.99713314, 0.0010777576, 5.544281e-06, 0.001717576, 3.16229e-05], [3.3162783e-06, 1.9481122e-06, 6.109842e-05, 1.107555e-06, 0.9994636, 0.00046889475], [0.9654007, 0.0035765944, 0.029874803, 0.0007518418, 9.026896e-05, 0.00030585245], [0.0005620858, 2.0990645e-05, 0.00019941368, 3.8246697e-05, 0.9985164, 0.0006629175], [1.0021851e-05, 0.00010295608, 4.558244e-06, 3.2593038e-05, 0.00013827618, 0.9997116], [0.00065268204, 0.11553527, 0.00087563845, 0.8486143, 0.014446004, 0.019876195], [3.3490596e-05, 0.00036338466, 2.0906486e-06, 4.5020583e-06, 0.9984364, 0.0011601481], [0.9997961, 1.701569e-05, 6.204296e-06, 0.00010434067, 4.8346326e-05, 2.80093e-05], [7.593594e-05, 0.0015425292, 0.00076400617, 1.1853539e-05, 0.9959998, 0.0016058171], [3.756573e-05, 3.2977784e-06, 0.00011061765, 2.3910782e-06, 0.9996619, 0.00018429446], [0.0005168042, 4.0630207e-06, 0.00014186335, 9.1208785e-06, 0.9984352, 0.00089293], [1.059817e-05, 5.778648e-05, 3.8712537e-06, 4.208864e-06, 0.9997416, 0.00018190686], [9.981557e-05, 0.00022464352, 8.926405e-06, 0.00016831138, 0.000791989, 0.9987062], [0.00016072328, 0.9955811, 0.00017715023, 0.00027429662, 0.0034201138, 0.00038666016], [0.00038162898, 3.8864822e-05, 4.750347e-05, 2.0400495e-05, 0.9995073, 4.2474453e-06], [0.0001953641, 6.8055815e-05, 0.000200668, 7.847155e-06, 0.00384652, 0.99568164], [0.0023555658, 0.79801995, 0.1278342, 0.009872395, 0.0014493148, 0.060468536], [1.9699994e-05, 2.673844e-05, 0.00023266044, 1.0668577e-05, 4.0077528e-05, 0.99967015], [0.9952048, 6.0041104e-05, 0.00028487202, 0.00040530955, 0.0039475765, 9.7443415e-05], [6.271294e-05, 5.224354e-05, 1.7129794e-05, 0.00015245996, 0.99967396, 4.1463056e-05], [7.578427e-05, 1.4564698e-05, 0.00028063954, 7.466497e-06, 8.81329e-05, 0.9995334], [5.958089e-05, 2.9733095e-05, 0.9992435, 6.754451e-07, 1.1855964e-05, 0.0006546855], [4.4752237e-06, 1.160202e-06, 1.1634614e-05, 4.3553493e-07, 1.5088391e-05, 0.9999671], [1.1641659e-05, 8.762868e-05, 0.0007569609, 3.3730373e-06, 0.99913377, 6.6394005e-06], [5.1063576e-05, 3.1696847e-05, 0.00014454547, 1.7785831e-05, 0.9982645, 0.0014904405], [1.4420998e-05, 8.357229e-07, 2.93477e-06, 2.3352025e-07, 2.6783728e-05, 0.9999548], [2.9056464e-08, 8.046926e-09, 2.7076563e-09, 3.129228e-09, 1.0, 8.698494e-09], [8.1750324e-05, 0.0009157964, 0.006869095, 0.00012108744, 2.7580116e-05, 0.9919848], [0.00036706444, 0.0010686824, 0.99716395, 2.5510733e-05, 0.0012044535, 0.00017038967], [8.514396e-06, 0.000112904345, 5.0546437e-06, 1.6965249e-06, 0.9998661, 5.7303714e-06], [5.8168866e-05, 0.99932957, 5.625062e-05, 0.00033388933, 3.888367e-05, 0.00018322394], [3.6204474e-05, 0.00032585175, 0.00017991572, 0.00012030203, 0.99933165, 6.0465613e-06], [0.00027409336, 0.0028785164, 0.0057730787, 4.2700438e-05, 0.99035734, 0.0006742268], [0.008998149, 0.0020925843, 0.9395738, 0.002177192, 0.011212088, 0.035946142], [0.05236688, 0.0026328776, 0.42008904, 0.00092166726, 0.012707169, 0.5112823], [1.3662913e-06, 3.3422225e-06, 1.3324684e-05, 8.1940937e-07, 0.99997973, 1.4290221e-06], [2.8709333e-05, 8.65371e-06, 4.0809675e-05, 2.67852e-06, 0.99988544, 3.3704757e-05], [1.9064824e-05, 8.412625e-06, 8.553466e-05, 1.8772381e-07, 0.99988616, 5.9034585e-07], [7.894143e-05, 8.371e-06, 0.00079885527, 1.695291e-06, 0.9991084, 3.7387874e-06], [0.0010965227, 6.854427e-05, 7.760317e-05, 2.0017116e-05, 0.00055618695, 0.9981812], [0.0014548243, 5.115249e-05, 0.99642795, 1.0440501e-06, 0.0020506736, 1.4263038e-05], [0.001152246, 0.00021093067, 0.010331046, 9.770586e-06, 0.98772264, 0.00057335646], [3.2760187e-07, 3.5113186e-05, 0.9999622, 2.7902766e-07, 2.9547013e-07, 1.7458818e-06], [2.5277009e-06, 4.913117e-06, 6.964924e-06, 1.1580972e-06, 0.9999832, 1.3364505e-06], [8.427378e-05, 7.289212e-05, 0.0001431556, 8.192274e-06, 0.9995493, 0.00014225848], [0.0003929598, 0.011132104, 6.5121356e-05, 0.0011249633, 0.0019643756, 0.9853205], [1.3171218e-06, 3.5009045e-06, 3.7294754e-05, 4.7362425e-07, 0.99994314, 1.4257092e-05], [0.39438167, 0.0017286014, 0.00032493993, 0.0008990323, 0.57731605, 0.025349764], [5.414873e-05, 0.00012150001, 0.00020906788, 0.00017998062, 0.99937856, 5.6598696e-05], [0.00014981766, 0.0005432433, 0.0008475171, 0.00017207977, 0.99797136, 0.00031606277], [3.8767907e-06, 7.4034324e-07, 1.3048981e-05, 1.7675501e-07, 0.99996173, 2.046132e-05], [1.5952372e-05, 0.95860034, 0.00011489859, 1.2939016e-05, 0.04114782, 0.000108118664], [3.5599953e-06, 2.2279166e-05, 5.5515837e-05, 1.1491754e-06, 0.99984384, 7.356449e-05], [0.0033311204, 0.0003831879, 0.00024211868, 0.0001649175, 0.9957098, 0.00016881713], [0.0021427542, 0.00037256672, 0.007704302, 2.6914771e-05, 0.000105511346, 0.9896479], [0.0010947735, 0.89787227, 0.004901295, 0.052842747, 0.024325205, 0.01896374], [7.556153e-08, 1.9007002e-05, 5.9896195e-08, 9.409651e-08, 0.9999758, 4.8523098e-06], [0.98385423, 2.769718e-05, 0.0007237124, 8.33519e-05, 0.0018718238, 0.013439039], [4.482766e-06, 6.223699e-06, 3.5390046e-06, 4.342299e-06, 0.99970275, 0.00027860425], [3.9287097e-05, 0.0020286934, 0.0008471617, 8.362652e-05, 0.9968947, 0.0001063732], [0.0129518965, 0.00033974875, 0.08617414, 0.00016099395, 0.69730043, 0.20307274], [2.6996162e-05, 1.084152e-05, 0.00022171428, 1.6419244e-06, 0.9996277, 0.000110937355], [5.8929345e-05, 6.492622e-05, 0.99986804, 3.7554253e-06, 6.2047457e-07, 3.7039154e-06], [0.00014001715, 0.00014139229, 0.90270936, 4.0953986e-05, 0.0012192992, 0.095749], [5.321392e-05, 0.005229926, 0.9947114, 8.4837706e-07, 1.0425964e-06, 3.5788794e-06], [0.5962114, 8.891845e-05, 0.00045324978, 0.013933459, 0.018822728, 0.37049025], [0.01565143, 0.16958201, 0.010636462, 0.13116585, 0.002017021, 0.6709472], [2.6996162e-05, 1.084152e-05, 0.00022171428, 1.6419244e-06, 0.9996277, 0.000110937355], [0.08493126, 0.00039129914, 0.27819133, 0.0005301628, 0.002267074, 0.6336889], [4.1572894e-05, 1.0464674e-05, 5.7111407e-05, 4.235746e-06, 0.9998714, 1.5242573e-05], [2.133291e-06, 6.2130794e-06, 6.4672317e-06, 1.1287385e-06, 0.9999156, 6.8471454e-05], [1.6995278e-06, 2.342457e-05, 1.42225235e-05, 4.236806e-07, 0.9999294, 3.0858777e-05], [0.0001755997, 5.640895e-05, 0.0018053413, 4.406857e-06, 0.9962534, 0.0017048786], [2.035718e-06, 1.3238883e-07, 7.22156e-07, 5.645577e-07, 0.9999943, 2.2428483e-06], [0.04246518, 0.00010571361, 0.56788075, 0.00022048036, 0.0035982258, 0.38572967], [0.001647752, 0.0002518864, 0.98668367, 0.00014124898, 0.0012370957, 0.010038363], [0.00042718378, 1.0114699e-05, 4.4205146e-05, 3.138485e-05, 0.00033253324, 0.9991547]])

import gradio as gr
from transformers import BertTokenizer, BertForSequenceClassification
import re
import torch
import cv2
import random
from sklearn.metrics.pairwise import cosine_similarity

tokenizer = BertTokenizer.from_pretrained(r'./model')
model = BertForSequenceClassification.from_pretrained(r'./model', num_labels = 6)

labels = ['伤感(sadness)', '快乐(happiness)', '励志(inspiration)', '宣泄(catharsis)', '平静(placid)', '感人(touching)']

def preprocess(temp):
    temp = re.sub(u"\n\n", "\n", temp)
    temp = re.sub(u"(^\n)|(\n$)", "", temp)
    temp = re.sub(u",", ",", temp)
    temp = re.sub(u"\?", "?", temp)
    temp = re.sub(u"!", "!", temp)
    temp = re.sub(u"\.", "。", temp)
    temp = re.sub('[^\u4e00-\u9fa5,。?!\n]+', '', temp)
    temp = re.sub(u"\n", ",", temp)
    for _ in range(int(len(temp) / 2)):
        temp = re.sub(u",,|!!|??|。。", ",", temp)
        temp = re.sub(u",!|!,", "!", temp)
        temp = re.sub(u",?|?,", "?", temp)
        temp = re.sub(u",。|。,", "。", temp)
    temp = temp.strip(',')

    return temp


def match_img(txt_vec):
    sim_matrix = []
    for vec in img_vec:
        # vec = vec.reshape(-1, 1)
        # txt_vec = txt_vec.reshape(-1, 1)
        sim = cosine_similarity([list(txt_vec)], [list(vec)])[0][0]
        print(sim)
        sim_matrix.append(sim)
    sim_matrix = np.array(sim_matrix)
    rank_idx = np.argsort(-sim_matrix)
    rd = random.randint(0,4)
    img_idx = rank_idx[rd]
    print(img_idx)
    if img_idx in [189, 205]:
        img_idx = 128
    
    return img_idx

def classify_text(input_chinese_lyrics):
    # print(inp)
    inp = preprocess(input_chinese_lyrics)
    # print(inp)
    inp = tokenizer(inp, padding=True, max_length=512, truncation=True, return_tensors="pt")
    # print(inp)
    with torch.no_grad():
        logits = model(**inp).logits
    # print(logits)
    # print(logits.shape)
    # logits = logits.argsort().squeeze(0)
    logits = torch.nn.Softmax(dim=1)(logits).squeeze(0).cpu().numpy()
    img_idx = match_img(logits)
    img_path = r'./imgs/' + str(img_idx) +'.png'
    img_output = cv2.imread(img_path)
    img_output = cv2.cvtColor(img_output,cv2.COLOR_BGR2RGB)
    
    # print(logits)
    #return {labels[i]: float(logits[i].item()) for i in range(len(labels))}
    return [{labels[i]: float(logits[i].item()) for i in range(len(labels))}, img_output]

gr.Interface(
    classify_text,
    # gr.inputs.Image(),
    gr.inputs.Textbox(lines=5,default=""),
    outputs = ['label','image']
    # inputs='image',
    # outputs='label',
    # examples=[["images/cheetah1.jpg"], ["images/lion.jpg"]],
).launch(debug=True)