使用svm进行蚊子识别
来源:互联网 发布:excel公开课数据分析 编辑:程序博客网 时间:2024/05/20 02:28
# -*- coding:utf-8 -*-'''@finish time:20170915@author;fengjiexybthis is a file that train and test LCD digitthe dataset is minethe result is 95.05%'''import loggingimport matplotlib.pyplot as pltimport numpy as npimport osimport pickleimport randomimport structfrom PCV.tools import imtoolsfrom PIL import Imagefrom svmutil import *import cv2Isize=75#read datasetdef load_data(path): files=os.listdir(path) features=[] label = [] for index in files: #img = Image.open(path + index) img = cv2.imread(path+index) if img is not None: res = cv2.resize(img, (Isize, Isize), interpolation=cv2.INTER_AREA) im=cv2.cvtColor(res,cv2.COLOR_BGR2GRAY) #im = np.array(img.resize((50, 50)).convert('L')) im=np.reshape(im, Isize*Isize) features.append(im) if int(index[0])==2: label.append(1) elif int(index[0])==3: label.append(1) else: label.append(int(index[0])) else: print index return np.array(features),label,files#add loglogging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', filename='myapp.log', filemode='w')# read train datafeatures,labels,trainfiles = load_data('C:/Users/fengjiexyb/Desktop/train/')# read test datatest_features,test_labels,testfiles = load_data('C:/Users/fengjiexyb/Desktop/test/')# train SVM classifierfeatures = map(list,features)test_features = map(list,test_features)prob = svm_problem(labels,features)param = svm_parameter('-t 0')m = svm_train(prob,param)# test reslutres = svm_predict(test_labels,test_features,m)for i in xrange(109): if abs(test_labels[i]-res[0][i])>0.5: print testfiles[i],test_labels[i],res[0][i]
数据集是自己做的,总计700+张蚊子,100+苍蝇、蚂蚁等图片作为训练。
识别结果
Accuracy = 78.4946% (73/93) (classification)
precision=77.3%
recall=98.5%
F value=86.6
阅读全文
0 0
- 使用svm进行蚊子识别
- SVM对文字识别的简单使用
- 使用android杀蚊子
- sklearn中SVM与AdaBoost对手写体数字进行识别
- 蚊子
- 蚊子
- 蚊子
- 使用MapReduce对svm模型进行训练
- 使用隐马尔科夫进行语音识别
- 使用opencv进行数字识别
- 使用GestureDetector进行手势识别
- 使用GestureDetector进行手势识别
- 使用GestrueDetector进行手势识别
- 使用GestureOverlayView进行手势识别
- 使用opencv的SVM实现车牌区域识别
- 使用opencv的SVM和神经网络实现车牌识别
- 使用opencv的SVM和神经网络实现车牌识别
- 使用opencv的SVM实现车牌区域识别
- 最简单的基于librtmp的示例:发布(FLV通过RTMP发布)
- 总结之linux下网络编程
- Salesforce中使用Apex Test Class(测试类)测试Extension类型实例
- PC端地图Hybird应用开发(百度地图API+C#+JavaScript)
- 下拉刷新和viewPager左右滑动冲突,下拉刷新和banner滑动布局滑动冲突
- 使用svm进行蚊子识别
- Spring Cloud 学习笔记——入门、特征、配置
- JavaWeb之Ajax
- 腾讯笔试题——用1,1,2,2,4,4,8,8...2^i,2^i拼凑成一个整数n,求问多少种拼凑方法
- Spring MVC HTTP Status 405
- 电子签名
- web前端开发vue笔记学习
- HTML+CSS+jquery 实现环形比例图效果 AngularJS+css实现环形比例图效果
- 获取俩个日期间 工作日天数——搬运工