-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYaprakTest.py
32 lines (23 loc) · 1.18 KB
/
YaprakTest.py
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
__author__ = 'altug'
from RGBHistogram import RGBHistogram
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import LabelEncoder
from TrainClassify import TrainClassify
import cv2
import glob
#****************************************************YAPRAK EGITIM***************************************************************
imagePaths = sorted(glob.glob("dataset/images" + "/*.png"))#YAPRAK Pathi verilecek.
maskPaths = sorted(glob.glob("dataset/masks" + "/*.png"))
trainObj = TrainClassify(imagePaths, maskPaths)
#****************************************************YAPRAK TEST***************************************************************
imagePath = 'testimg.jpg'
image = cv2.imread(imagePath)
rgbHistObj = RGBHistogram([8, 8, 8])
features = rgbHistObj.calculateHist(image, mask=None)
flower = trainObj.le.inverse_transform(trainObj.model.predict(features))[0] #Burada ilk feature i isim olarak aliyor bunu integerdan ceviriyor.
print imagePath
if flower == 'crocus' : flower = 'cigdem'
if flower == 'daisy' : flower = 'papatya'
if flower == 'pansy' : flower = 'menekse'
if flower == 'sunflower' : flower = 'aycicegi'
print "Bu cicek %s olabilir." % (flower.upper())