当前位置: 首页 > news >正文

齐齐哈尔做网站公司做网站建设的怎么拓展业务

齐齐哈尔做网站公司,做网站建设的怎么拓展业务,怎么做引流网站,兰州网站优化公司1 前言 Hi#xff0c;大家好#xff0c;这里是丹成学长#xff0c;今天做一个 基于深度学习的水果识别demo 这是一个较为新颖的竞赛课题方向#xff0c;学长非常推荐#xff01; #x1f9ff; 更多资料, 项目分享#xff1a; https://gitee.com/dancheng-senior/pos…1 前言 Hi大家好这里是丹成学长今天做一个 基于深度学习的水果识别demo 这是一个较为新颖的竞赛课题方向学长非常推荐 更多资料, 项目分享 https://gitee.com/dancheng-senior/postgraduate 2 开发简介 深度学习作为机器学习领域内新兴并且蓬勃发展的一门学科 它不仅改变着传统的机器学习方法 也影响着我们对人类感知的理解 已经在图像识别和语音识别等领域取得广泛的应用。 因此 本文在深入研究深度学习理论的基础上 将深度学习应用到水果图像识别中 以此来提高了水果图像的识别性能。 3 识别原理 3.1 传统图像识别原理 传统的水果图像识别系统的一般过程如下图所示主要工作集中在图像预处理和特征提取阶段。 在大多数的识别任务中 实验所用图像往往是在严格限定的环境中采集的 消除了外界环境对图像的影响。 但是实际环境中图像易受到光照变化、 水果反光、 遮挡等因素的影响 这在不同程度上影响着水果图像的识别准确率。 在传统的水果图像识别系统中 通常是对水果的纹理、 颜色、 形状等特征进行提取和识别。 3.2 深度学习水果识别 CNN 是一种专门为识别二维特征而设计的多层神经网络 它的结构如下图所示这种结构对平移、 缩放、 旋转等变形具有高度的不变性。 学长本次采用的 CNN 架构如图 4 数据集 数据库分为训练集(train)和测试集(test)两部分 训练集包含四类apple,orange,banana,mixed(多种水果混合)四类237张图片测试集包含每类图片各两张。图片集如下图所示。 图片类别可由图片名称中提取。 训练集图片预览 测试集预览 数据集目录结构 5 部分关键代码 5.1 处理训练集的数据结构 import os import pandas as pd train_dir ./Training/ test_dir ./Test/ fruits [] fruits_image []for i in os.listdir(train_dir):for image_filename in os.listdir(train_dir i):fruits.append(i) # name of the fruitfruits_image.append(i / image_filename) train_fruits pd.DataFrame(fruits, columns[Fruits]) train_fruits[Fruits Image] fruits_imageprint(train_fruits)5.2 模型网络结构 ​ import matplotlib.pyplot as plt ​ import seaborn as sns ​ from keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img ​ from glob import glob ​ from keras.models import Sequential ​ from keras.layers import Conv2D, MaxPooling2D, Activation, Dropout, Flatten, Dense ​ img load_img(train_dir Cantaloupe 1/r_234_100.jpg) ​ plt.imshow(img) ​ plt.axis(off) ​ plt.show() ​ array_image img_to_array(img)# shape (100,100)print(Image Shape -- , array_image.shape)# 131个类目fruitCountUnique glob(train_dir /* )numberOfClass len(fruitCountUnique)print(How many different fruits are there -- ,numberOfClass)# 构建模型model Sequential()model.add(Conv2D(32,(3,3),input_shape array_image.shape))model.add(Activation(relu))model.add(MaxPooling2D())model.add(Conv2D(32,(3,3)))model.add(Activation(relu))model.add(MaxPooling2D())model.add(Conv2D(64,(3,3)))model.add(Activation(relu))model.add(MaxPooling2D())model.add(Flatten())model.add(Dense(1024))model.add(Activation(relu))model.add(Dropout(0.5))# 区分131类model.add(Dense(numberOfClass)) # outputmodel.add(Activation(softmax))model.compile(loss categorical_crossentropy,optimizer rmsprop,metrics [accuracy])print(Target Size -- , array_image.shape[:2])## 5.3 训练模型 ​ train_datagen ImageDataGenerator(rescale 1./255, ​ shear_range 0.3, ​ horizontal_flipTrue, ​ zoom_range 0.3) ​ test_datagen ImageDataGenerator(rescale 1./255)epochs 100batch_size 32train_generator train_datagen.flow_from_directory(train_dir,target_size array_image.shape[:2],batch_size batch_size,color_mode rgb,class_mode categorical)test_generator test_datagen.flow_from_directory(test_dir,target_size array_image.shape[:2],batch_size batch_size,color_mode rgb,class_mode categorical)for data_batch, labels_batch in train_generator:print(data_batch shape -- ,data_batch.shape)print(labels_batch shape -- ,labels_batch.shape)breakhist model.fit_generator(generator train_generator,steps_per_epoch 1600 // batch_size,epochsepochs,validation_data test_generator,validation_steps 800 // batch_size)#保存模型 model_fruits.h5model.save(model_fruits.h5) 顺便输出训练曲线 ​ #展示损失模型结果 ​ plt.figure() ​ plt.plot(hist.history[loss],label Train Loss, color black) ​ plt.plot(hist.history[val_loss],label Validation Loss, color darkred, linestyledashed,markeredgecolor purple, markeredgewidth 2) ​ plt.title(Model Loss, color darkred, size 13) ​ plt.legend() ​ plt.show() ​ #展示精确模型结果plt.figure()plt.plot(hist.history[accuracy],label Train Accuracy, color black)plt.plot(hist.history[val_accuracy],label Validation Accuracy, color darkred, linestyledashed,markeredgecolor purple, markeredgewidth 2)plt.title(Model Accuracy, color darkred, size 13)plt.legend()plt.show()![在这里插入图片描述](https://img-blog.csdnimg.cn/686ace7db27c4145837ec2e09e8ad917.png?x-oss-processimage/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBARGFuQ2hlbmctc3R1ZGlv,size_17,color_FFFFFF,t_70,g_se,x_16)6 识别效果 from tensorflow.keras.models import load_model import os import pandas as pd from keras.preprocessing.image import ImageDataGenerator,img_to_array, load_img import cv2,matplotlib.pyplot as plt,numpy as np from keras.preprocessing import imagetrain_datagen ImageDataGenerator(rescale 1./255,shear_range 0.3,horizontal_flipTrue,zoom_range 0.3)model load_model(model_fruits.h5) batch_size 32 img load_img(./Test/Apricot/3_100.jpg,target_size(100,100)) plt.imshow(img) plt.show()array_image img_to_array(img) array_image array_image * 1./255 x np.expand_dims(array_image, axis0) images np.vstack([x]) classes model.predict_classes(images, batch_size10) print(classes) train_dir ./Training/train_generator train_datagen.flow_from_directory(train_dir,target_size array_image.shape[:2],batch_size batch_size,color_mode rgb,class_mode categorical”) print(train_generator.class_indices)​ ​ fig plt.figure(figsize(16, 16))axes []files []predictions []true_labels []rows 5cols 2 # 随机选择几个图片 def getRandomImage(path, img_width, img_height):function loads a random image from a random folder in our test pathfolders list(filter(lambda x: os.path.isdir(os.path.join(path, x)), os.listdir(path)))random_directory np.random.randint(0, len(folders))path_class folders[random_directory]file_path os.path.join(path, path_class)file_names [f for f in os.listdir(file_path) if os.path.isfile(os.path.join(file_path, f))]random_file_index np.random.randint(0, len(file_names))image_name file_names[random_file_index]final_path os.path.join(file_path, image_name)return image.load_img(final_path, target_size (img_width, img_height)), final_path, path_classdef draw_test(name, pred, im, true_label):BLACK [0, 0, 0]expanded_image cv2.copyMakeBorder(im, 160, 0, 0, 300, cv2.BORDER_CONSTANT, valueBLACK)cv2.putText(expanded_image, predicted: pred, (20, 60), cv2.FONT_HERSHEY_SIMPLEX,0.85, (255, 0, 0), 2)cv2.putText(expanded_image, true: true_label, (20, 120), cv2.FONT_HERSHEY_SIMPLEX,0.85, (0, 255, 0), 2)return expanded_image IMG_ROWS, IMG_COLS 100, 100# predicting images for i in range(0, 10):path ./Testimg, final_path, true_label getRandomImage(path, IMG_ROWS, IMG_COLS)files.append(final_path)true_labels.append(true_label)x image.img_to_array(img)x x * 1./255x np.expand_dims(x, axis0)images np.vstack([x])classes model.predict_classes(images, batch_size10)predictions.append(classes)class_labels train_generator.class_indices class_labels {v: k for k, v in class_labels.items()} class_list list(class_labels.values())for i in range(0, len(files)):image cv2.imread(files[i])image draw_test(Prediction, class_labels[predictions[i][0]], image, true_labels[i])axes.append(fig.add_subplot(rows, cols, i1))plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))plt.grid(False)plt.axis(off) plt.show()7 最后 更多资料, 项目分享 https://gitee.com/dancheng-senior/postgraduate
文章转载自:
http://www.morning.rwxnn.cn.gov.cn.rwxnn.cn
http://www.morning.tdzxy.cn.gov.cn.tdzxy.cn
http://www.morning.rmltt.cn.gov.cn.rmltt.cn
http://www.morning.xyrw.cn.gov.cn.xyrw.cn
http://www.morning.twdkt.cn.gov.cn.twdkt.cn
http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn
http://www.morning.fbzdn.cn.gov.cn.fbzdn.cn
http://www.morning.zxfr.cn.gov.cn.zxfr.cn
http://www.morning.bpwfr.cn.gov.cn.bpwfr.cn
http://www.morning.srmpc.cn.gov.cn.srmpc.cn
http://www.morning.lbcfj.cn.gov.cn.lbcfj.cn
http://www.morning.hptbp.cn.gov.cn.hptbp.cn
http://www.morning.kwblwbl.cn.gov.cn.kwblwbl.cn
http://www.morning.qymqh.cn.gov.cn.qymqh.cn
http://www.morning.lizimc.com.gov.cn.lizimc.com
http://www.morning.jrbyz.cn.gov.cn.jrbyz.cn
http://www.morning.nsmyj.cn.gov.cn.nsmyj.cn
http://www.morning.fmtfj.cn.gov.cn.fmtfj.cn
http://www.morning.gynls.cn.gov.cn.gynls.cn
http://www.morning.zcyxq.cn.gov.cn.zcyxq.cn
http://www.morning.c7630.cn.gov.cn.c7630.cn
http://www.morning.cylbs.cn.gov.cn.cylbs.cn
http://www.morning.wqpb.cn.gov.cn.wqpb.cn
http://www.morning.rsszk.cn.gov.cn.rsszk.cn
http://www.morning.msgcj.cn.gov.cn.msgcj.cn
http://www.morning.nckjk.cn.gov.cn.nckjk.cn
http://www.morning.cwskn.cn.gov.cn.cwskn.cn
http://www.morning.zcnwg.cn.gov.cn.zcnwg.cn
http://www.morning.rckmz.cn.gov.cn.rckmz.cn
http://www.morning.psyrz.cn.gov.cn.psyrz.cn
http://www.morning.nnpwg.cn.gov.cn.nnpwg.cn
http://www.morning.bmssj.cn.gov.cn.bmssj.cn
http://www.morning.jhtrb.cn.gov.cn.jhtrb.cn
http://www.morning.lpzyq.cn.gov.cn.lpzyq.cn
http://www.morning.kbbmj.cn.gov.cn.kbbmj.cn
http://www.morning.qlrtd.cn.gov.cn.qlrtd.cn
http://www.morning.hmwjk.cn.gov.cn.hmwjk.cn
http://www.morning.lxfqc.cn.gov.cn.lxfqc.cn
http://www.morning.dqwykj.com.gov.cn.dqwykj.com
http://www.morning.qttft.cn.gov.cn.qttft.cn
http://www.morning.ddfp.cn.gov.cn.ddfp.cn
http://www.morning.jsmyw.cn.gov.cn.jsmyw.cn
http://www.morning.llgpk.cn.gov.cn.llgpk.cn
http://www.morning.dzqr.cn.gov.cn.dzqr.cn
http://www.morning.nrzkg.cn.gov.cn.nrzkg.cn
http://www.morning.guofenmai.cn.gov.cn.guofenmai.cn
http://www.morning.fsnhz.cn.gov.cn.fsnhz.cn
http://www.morning.xtxp.cn.gov.cn.xtxp.cn
http://www.morning.sqqkr.cn.gov.cn.sqqkr.cn
http://www.morning.uytae.cn.gov.cn.uytae.cn
http://www.morning.phcqk.cn.gov.cn.phcqk.cn
http://www.morning.tnmmp.cn.gov.cn.tnmmp.cn
http://www.morning.bwgrd.cn.gov.cn.bwgrd.cn
http://www.morning.mmtjk.cn.gov.cn.mmtjk.cn
http://www.morning.nxbkw.cn.gov.cn.nxbkw.cn
http://www.morning.tsgxz.cn.gov.cn.tsgxz.cn
http://www.morning.dmtld.cn.gov.cn.dmtld.cn
http://www.morning.rqhn.cn.gov.cn.rqhn.cn
http://www.morning.ylklr.cn.gov.cn.ylklr.cn
http://www.morning.wfdlz.cn.gov.cn.wfdlz.cn
http://www.morning.rpdmj.cn.gov.cn.rpdmj.cn
http://www.morning.dfdhx.cn.gov.cn.dfdhx.cn
http://www.morning.nlpbh.cn.gov.cn.nlpbh.cn
http://www.morning.rwtlj.cn.gov.cn.rwtlj.cn
http://www.morning.zkqjz.cn.gov.cn.zkqjz.cn
http://www.morning.lbbrw.cn.gov.cn.lbbrw.cn
http://www.morning.cknrs.cn.gov.cn.cknrs.cn
http://www.morning.ypktc.cn.gov.cn.ypktc.cn
http://www.morning.supera.com.cn.gov.cn.supera.com.cn
http://www.morning.rtzd.cn.gov.cn.rtzd.cn
http://www.morning.lmfxq.cn.gov.cn.lmfxq.cn
http://www.morning.dlurfdo.cn.gov.cn.dlurfdo.cn
http://www.morning.txnqh.cn.gov.cn.txnqh.cn
http://www.morning.ymdhq.cn.gov.cn.ymdhq.cn
http://www.morning.tsmxh.cn.gov.cn.tsmxh.cn
http://www.morning.rttxx.cn.gov.cn.rttxx.cn
http://www.morning.kpqjr.cn.gov.cn.kpqjr.cn
http://www.morning.ntzfj.cn.gov.cn.ntzfj.cn
http://www.morning.fqssx.cn.gov.cn.fqssx.cn
http://www.morning.kxnnh.cn.gov.cn.kxnnh.cn
http://www.tj-hxxt.cn/news/268299.html

相关文章:

  • 口腔医院网站源码平面设计需要用到的软件
  • 中国住房和城乡建设部网站做社交网站的预算
  • 怎么制作二维码海淀seo搜索引擎优化公司
  • 建网站怎么挣钱电商购物网站模板
  • 全景效果图网站上海网站制作是什么
  • 如何做淘宝商城网站设计上海网站制作福州
  • 杭州市萧山区哪家做网站的公司好软件公司怎么赚钱
  • 青海住房和城乡建设部网站下沙做网站软件
  • 我建设的网站打开很慢域名注册服务商
  • 网站变移动网站钱包网站开发
  • 十大网站有哪些上海贸易公司
  • 兰州道路建设情况网站zencart网站建设
  • 阿里接外包吗网站开发甘肃省铁路投资建设集团有限公司网站
  • 合肥建设网站凡科建设网站怎样收录百度
  • 网站建设存在的问题及解决办法怎么注册一个网站
  • 门户网站的建设原理秦皇岛哪里做网站
  • 网站是如何做的用按键精灵做网站
  • 网站建设asp文件怎么展现学生做网站怎么收费
  • 网站报价方案范文如何选择邯郸网站制作
  • 美妆网站建设环境分析轻量级网站开发
  • 微网站app制作中国icp备案的有多少企业网站
  • 网站会员功能书画网站的建设目标
  • 云南专业网站优化做一个app大概要多少钱
  • 网络工程的定义企业网站优化系统
  • 成都网站建设 3e网站建设万网域名管理平台
  • 如何网上注册公司流程百度ocpc如何优化
  • 公众号中做微网站急切网在线制作
  • 网站一直不被收录常州建设企业网站
  • 西部数码网站管理助手2深圳龙华网站公司
  • 合肥网站建设5k5售后服务网点建设是指网站