-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTacTest.py
40 lines (31 loc) · 1.55 KB
/
TacTest.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
33
34
35
36
37
38
39
40
__author__ = 'altug'
from RGBHistogram import RGBHistogram
from Adaptive import Adaptive
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import LabelEncoder
from TrainClassify import TrainClassify
import cv2
import glob
import numpy as np
#****************************************************TAC EGITIM***************************************************************
imagePaths = sorted(glob.glob("dataset/imagesjpg" + "/*.jpg"))#Egitim path i.
maskPaths = sorted(glob.glob("dataset/masksjpg" + "/*.jpg"))
trainObj = TrainClassify(imagePaths, maskPaths)
#****************************************************TAC TEST***************************************************************
#adaptiveObj = Adaptive()
testPaths = sorted(glob.glob("test" + "/*.jpg"))
for testPath in testPaths:
image = cv2.imread(testPath)
#threshImage = adaptiveObj.getThresh(imagePath)
#convertedThresh = cv2.cvtColor(threshImage, cv2.COLOR_GRAY2BGR)
#masked_img = cv2.bitwise_and(image,image,mask = threshImage)
#cv2.imshow("asdasd", masked_img)
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 testPath
if flower == 'crocus': flower = 'cigdem'
if flower == 'daisy': flower = 'papatya'
if flower == 'pansy' : flower = 'menekse'
if flower == 'sunflower' : flower = 'aycicegi'
print "Bu cicek %s cinsi olabilir." % (flower.upper())