识别花卉最好的软件下载,识别花的软件哪个最准

  识别花卉最好的软件下载,识别花的软件哪个最准

  代码:

  #!/usr/bin/env python #-*-编码:utf-8-*-# @时间:2020/3/7 15:40 # @作者:Shark # @站点:# @文件:flower _ image _ test。py # @ Software:py charm from _ _ future _ _ import absolute _ import,division,print_function,unicode _ literals导入警告警告。过滤警告(忽略)#导入模块导入glob导入OSI导入cv2导入张量流作为TF导入numpy作为NP导入matplotlib。py绘图为来自sk learn的PLT。从张量流导入训练测试分割。python。keras导入层,优化器,从张量流顺序导入h5py #。compat。v1从张量流导入配置协议号。compat。v1导入交互会话# # config=config proto()# config。GPU _选项。allow _ growth=True # session=interactive session(config=config)# # jpg ):# print( image path: im img=cv2。im read(im)img=cv2。resize(img,(w,h))# print(img)imgs。附加(img)标签。append(idx)返回NP。as数组(imgs,np.float32),np.asarray(labels,np.int32)数据,labels=read_image()print(data的维度:,data.shape)打印(标签的维度:,标签。形状)种子=785 NP。随机的。seed(种子)(x _ train,x_val,y_train,y_val)=train_test_split(data,labels,test_size=0.20,random _ state=seed)x _ train=x _ train/255 x _ val=x _ val/255 # print(x _ train[0])# dasiy:雏菊蒲公英:蒲公英玫瑰:玫瑰花向日葵:向日葵图普里斯:郁金香flower_dict={0:dasiy ,1:蒲公英,2:玫瑰,3:向日葵,4: tuplis }模型=顺序([层.Conv2D(32,kernel_size=[5,5],padding=same ,activation=tf.nn.relu),layers .MaxPool2D(pool_size=[2,2],strides=2,padding=same ),层。辍学(0.25),层Conv2D(64,kernel_size=[3,3],padding=same ,activation=tf.nn.relu),layers .Conv2D(64,kernel_size=[3,3],padding=same ,activation=tf.nn.relu),layers .MaxPool2D(pool_size=[2,2],strides=2,padding=same ),层。辍学(0.25),层Conv2D(128,kernel_size=[3,3],padding=same ,activation=tf.nn.relu),layers .MaxPool2D(pool_size=[2,2],strides=2,padding=same ),层。辍学(0.25),层。展平(),图层。密集(512,activation=tf.nn.relu),层。密集(256,activation=tf.nn.relu),层。密集(5,激活朴素的草丛,])op=优化器。现代的火龙果(lr=0.0001)模型。编译(optimizer=op,metrics=[accuracy],loss= sparse _ category _ cross entropy )模型。fit(x _ train,y_train,batch_size=200,epochs=20,validation_data=(x_val,y_val),verbose=2)模型。summary()#模型。保存( D:/软件/华为/model 6。H5 )# test _ path= D:/software/Huawei/test _ photos/ test _ path= jpg ):print(img)image _ name。追加(img)img=cv2。imread(img)img=cv2。resize(img,(w,h))img 2。追加(img)img 2=NP。as array(img 2,np.float32)print(测试集的大小:,img 2。形状)预测=模型。范围(NP)中I的predict _ classes(img 2)。size(predict)):print(image _ name[I])print(第,(i 1),张图片的预测结果: ,flower _ dict[predict[I]])img=PLT。im read(image _ name[I])PLT。im显示(img)PLT。显示()

识别花卉最好的软件下载,识别花的软件哪个最准