import numpy as np
from PIL import Image
from siamese import Siamese
if __name__ == "__main__":
model = Siamese()
import os
jj=[]
bone_path = "./datasets/images_background/"
data=os.listdir("./datasets/images_background")
data=sorted(data)
for i in range(250,len(data)):
j=sorted(os.listdir(os.path.join(bone_path,data[i])))[0]
jj.append(j)
ii=[]
for i in range(len(data)):
j=sorted(os.listdir(os.path.join(bone_path,data[i])))[1]
ii.append(j)
cc={}
for i in range(len(jj)):
b1=jj[i]
b=str(b1).split("_")[0]+ ".png"
print(b1)
cc[b1]={}
for j in range(len(ii)):
a1 = ii[j]
a = str(a1).split("_")[0] + ".png"
probability = model.detect_image(Image.open(os.path.join(bone_path,b,b1)),Image.open(os.path.join(bone_path,a,a1)))
cc[b1][a1]=probability
print(sorted(cc[b1].items(),key=lambda item:item[1])[-1])
print("***********************")
【笔记】python 中dict嵌套dict:按子dict的值进行升序
最新推荐文章于 2022-11-14 23:05:28 发布