Commit f6d01e6f authored by SCtom's avatar SCtom

Accuracy Up++

parent f8ae4ea1
sessions/session-4/Image/0/1.png

415 Bytes | W: | H:

sessions/session-4/Image/0/1.png

463 Bytes | W: | H:

sessions/session-4/Image/0/1.png
sessions/session-4/Image/0/1.png
sessions/session-4/Image/0/1.png
sessions/session-4/Image/0/1.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/10.png

432 Bytes | W: | H:

sessions/session-4/Image/0/10.png

458 Bytes | W: | H:

sessions/session-4/Image/0/10.png
sessions/session-4/Image/0/10.png
sessions/session-4/Image/0/10.png
sessions/session-4/Image/0/10.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/11.png

442 Bytes | W: | H:

sessions/session-4/Image/0/11.png

393 Bytes | W: | H:

sessions/session-4/Image/0/11.png
sessions/session-4/Image/0/11.png
sessions/session-4/Image/0/11.png
sessions/session-4/Image/0/11.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/12.png

476 Bytes | W: | H:

sessions/session-4/Image/0/12.png

421 Bytes | W: | H:

sessions/session-4/Image/0/12.png
sessions/session-4/Image/0/12.png
sessions/session-4/Image/0/12.png
sessions/session-4/Image/0/12.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/2.png

400 Bytes | W: | H:

sessions/session-4/Image/0/2.png

397 Bytes | W: | H:

sessions/session-4/Image/0/2.png
sessions/session-4/Image/0/2.png
sessions/session-4/Image/0/2.png
sessions/session-4/Image/0/2.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/3.png

452 Bytes | W: | H:

sessions/session-4/Image/0/3.png

424 Bytes | W: | H:

sessions/session-4/Image/0/3.png
sessions/session-4/Image/0/3.png
sessions/session-4/Image/0/3.png
sessions/session-4/Image/0/3.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/4.png

437 Bytes | W: | H:

sessions/session-4/Image/0/4.png

388 Bytes | W: | H:

sessions/session-4/Image/0/4.png
sessions/session-4/Image/0/4.png
sessions/session-4/Image/0/4.png
sessions/session-4/Image/0/4.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/5.png

456 Bytes | W: | H:

sessions/session-4/Image/0/5.png

411 Bytes | W: | H:

sessions/session-4/Image/0/5.png
sessions/session-4/Image/0/5.png
sessions/session-4/Image/0/5.png
sessions/session-4/Image/0/5.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/6.png

460 Bytes | W: | H:

sessions/session-4/Image/0/6.png

401 Bytes | W: | H:

sessions/session-4/Image/0/6.png
sessions/session-4/Image/0/6.png
sessions/session-4/Image/0/6.png
sessions/session-4/Image/0/6.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/7.png

452 Bytes | W: | H:

sessions/session-4/Image/0/7.png

404 Bytes | W: | H:

sessions/session-4/Image/0/7.png
sessions/session-4/Image/0/7.png
sessions/session-4/Image/0/7.png
sessions/session-4/Image/0/7.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/8.png

459 Bytes | W: | H:

sessions/session-4/Image/0/8.png

414 Bytes | W: | H:

sessions/session-4/Image/0/8.png
sessions/session-4/Image/0/8.png
sessions/session-4/Image/0/8.png
sessions/session-4/Image/0/8.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/0/9.png

449 Bytes | W: | H:

sessions/session-4/Image/0/9.png

459 Bytes | W: | H:

sessions/session-4/Image/0/9.png
sessions/session-4/Image/0/9.png
sessions/session-4/Image/0/9.png
sessions/session-4/Image/0/9.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/1.png

282 Bytes | W: | H:

sessions/session-4/Image/1/1.png

252 Bytes | W: | H:

sessions/session-4/Image/1/1.png
sessions/session-4/Image/1/1.png
sessions/session-4/Image/1/1.png
sessions/session-4/Image/1/1.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/10.png

297 Bytes | W: | H:

sessions/session-4/Image/1/10.png

267 Bytes | W: | H:

sessions/session-4/Image/1/10.png
sessions/session-4/Image/1/10.png
sessions/session-4/Image/1/10.png
sessions/session-4/Image/1/10.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/11.png

292 Bytes | W: | H:

sessions/session-4/Image/1/11.png

310 Bytes | W: | H:

sessions/session-4/Image/1/11.png
sessions/session-4/Image/1/11.png
sessions/session-4/Image/1/11.png
sessions/session-4/Image/1/11.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/12.png

287 Bytes | W: | H:

sessions/session-4/Image/1/12.png

243 Bytes | W: | H:

sessions/session-4/Image/1/12.png
sessions/session-4/Image/1/12.png
sessions/session-4/Image/1/12.png
sessions/session-4/Image/1/12.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/13.png

277 Bytes | W: | H:

sessions/session-4/Image/1/13.png

291 Bytes | W: | H:

sessions/session-4/Image/1/13.png
sessions/session-4/Image/1/13.png
sessions/session-4/Image/1/13.png
sessions/session-4/Image/1/13.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/2.png

246 Bytes | W: | H:

sessions/session-4/Image/1/2.png

277 Bytes | W: | H:

sessions/session-4/Image/1/2.png
sessions/session-4/Image/1/2.png
sessions/session-4/Image/1/2.png
sessions/session-4/Image/1/2.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/3.png

255 Bytes | W: | H:

sessions/session-4/Image/1/3.png

257 Bytes | W: | H:

sessions/session-4/Image/1/3.png
sessions/session-4/Image/1/3.png
sessions/session-4/Image/1/3.png
sessions/session-4/Image/1/3.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/4.png

290 Bytes | W: | H:

sessions/session-4/Image/1/4.png

263 Bytes | W: | H:

sessions/session-4/Image/1/4.png
sessions/session-4/Image/1/4.png
sessions/session-4/Image/1/4.png
sessions/session-4/Image/1/4.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/5.png

303 Bytes | W: | H:

sessions/session-4/Image/1/5.png

274 Bytes | W: | H:

sessions/session-4/Image/1/5.png
sessions/session-4/Image/1/5.png
sessions/session-4/Image/1/5.png
sessions/session-4/Image/1/5.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/6.png

270 Bytes | W: | H:

sessions/session-4/Image/1/6.png

283 Bytes | W: | H:

sessions/session-4/Image/1/6.png
sessions/session-4/Image/1/6.png
sessions/session-4/Image/1/6.png
sessions/session-4/Image/1/6.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/7.png

263 Bytes | W: | H:

sessions/session-4/Image/1/7.png

264 Bytes | W: | H:

sessions/session-4/Image/1/7.png
sessions/session-4/Image/1/7.png
sessions/session-4/Image/1/7.png
sessions/session-4/Image/1/7.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/8.png

268 Bytes | W: | H:

sessions/session-4/Image/1/8.png

270 Bytes | W: | H:

sessions/session-4/Image/1/8.png
sessions/session-4/Image/1/8.png
sessions/session-4/Image/1/8.png
sessions/session-4/Image/1/8.png
  • 2-up
  • Swipe
  • Onion skin
sessions/session-4/Image/1/9.png

289 Bytes | W: | H:

sessions/session-4/Image/1/9.png

305 Bytes | W: | H:

sessions/session-4/Image/1/9.png
sessions/session-4/Image/1/9.png
sessions/session-4/Image/1/9.png
sessions/session-4/Image/1/9.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -71,6 +71,17 @@ class Board(QWidget):
pixmap.save(label+'/'+str(max(cnt,maxf)+1)+'.png')
QFile.remove('tmp.png')
def saveImageTest(self):
import os
visibleImage = self.image
self.resizeImage(visibleImage,self.size())
if QDir('Test').exists() == False:
QDir().mkdir('Test')
visibleImage.save('tmp.png')
pixmap = QPixmap('tmp.png').scaled(64,64)
pixmap.save('Test/temp.png')
QFile.remove('tmp.png')
def paintEvent(self, event):
painter = QPainter(self)
......@@ -117,4 +128,4 @@ class Board(QWidget):
newImage.fill(qRgb(255,255,255))
painter = QPainter(newImage)
painter.drawImage(QPoint(0,0), image)
self.image = newImage
self.image = newImage
\ No newline at end of file
......@@ -37,13 +37,8 @@ class MainWindow(QWidget):
def on_clear(self):
self.scribbleArea.clearImage()
def data_prep(self):
def data_prep_train(self):
print('preporcessing..')
def on_train(self):
self.data_prep()
print('training..')
list_of_label = os.listdir('Image/')
digit_data = list()
digit_label = list()
......@@ -54,7 +49,7 @@ class MainWindow(QWidget):
for data in list_of_data:
im = Image.open(label_path+'/'+data)
arr_im = np.array(im)
list_im = str(arr_im.tolist())
#list_im = str(arr_im.tolist())
width, height = im.size
gen_data = np.zeros(width*height)
......@@ -62,16 +57,38 @@ class MainWindow(QWidget):
for i in range(len(arr_im)):
for j in range(len(arr_im[i])):
#ทำ Normalize ด้วยการ (R+G+B) หาร 765 มาจาก (255+255+255)
gen_data[count] = math.floor(((np.sum(arr_im[i][j][:3])/765)))
gen_data[count] = math.floor(((np.sum(arr_im[i][j][:3]/765))))
count+=1
digit_data.append( gen_data )
digit_label.append( label )
digit_data = np.array(digit_data) #ข้อมูล
digit_label = np.array(digit_label) # label ของข้อมูล
return digit_data,digit_label
def data_prep_test(self):
im = Image.open('Test/temp.png')
iar = np.array(im)
#list_im = str(arr_im.tolist())
width, height = im.size
test_data = np.zeros(width*height)
test_data = np.zeros(64*64)
count = 0
for i in range(len(iar)):
for j in range(len(iar[i])):
test_data[count] = math.floor(((np.sum(iar[i][j][:3]/765))))
#print(test_data[count])
count+=1
return test_data
def on_train(self):
digit_data, digit_label = self.data_prep_train()
print('training..')
# Create a classifier: a support vector classifier
classifier = svm.SVC(gamma=0.001, C=.1)
classifier = svm.SVC(gamma=0.001)
# We learn the digits on the first half of the digits
classifier.fit(digit_data, digit_label)
......@@ -83,32 +100,20 @@ class MainWindow(QWidget):
print("Classification report for classifier %s:\n%s\n"
% (classifier, metrics.classification_report(expected, predicted)))
print("Confusion matrix:\n%s" % metrics.confusion_matrix(expected, predicted))
print("\naccuracy = ",accuracy_score(digit_label, predicted))
def on_save(self):
print('on_save')
self.scribbleArea.saveImage(self.saveCombo.text())
self.scribbleArea.clearImage()
print("\naccuracy = ",accuracy_score(digit_label, predicted))
def on_test(self):
print("testing...")
clf = joblib.load('svmModel.pkl')
print('preporcessing..')
i = Image.open('test/t.png')
iar = np.array(i)
test_data = np.zeros(64*64)
len(iar[0])
count = 0
for i in range(len(iar)):
for j in range(len(iar[i])):
test_data[count] = math.floor(((np.sum(iar[i][j][:3])/765)))
#print(test_data[count])
count+=1
self.scribbleArea.saveImageTest()
test_data = self.data_prep_test()
predicted = clf.predict([test_data])
print(predicted)
print("ผลการทำนาย คือ", predicted)
def on_save(self):
print('on_save')
self.scribbleArea.saveImage(self.saveCombo.text())
self.scribbleArea.clearImage()
if __name__ == '__main__':
import sys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment