改变了模型路径和特征
3
.gitignore
vendored
Executable file → Normal file
@ -11,4 +11,5 @@ data5
|
|||||||
__pycache__
|
__pycache__
|
||||||
*.pyc
|
*.pyc
|
||||||
test.py
|
test.py
|
||||||
*.log
|
*.log
|
||||||
|
.models
|
||||||
10
classifer.py
Executable file → Normal file
@ -21,7 +21,7 @@ sys.path.append(os.getcwd())
|
|||||||
from root_dir import ROOT_DIR
|
from root_dir import ROOT_DIR
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
FEATURE_INDEX = [1, 2]
|
FEATURE_INDEX = [0, 1, 2, 6, 7]
|
||||||
|
|
||||||
|
|
||||||
class WoodClass(object):
|
class WoodClass(object):
|
||||||
@ -141,7 +141,7 @@ class WoodClass(object):
|
|||||||
cv2.imwrite(str(self.image_num) + ".bmp", img)
|
cv2.imwrite(str(self.image_num) + ".bmp", img)
|
||||||
self.image_num += 1
|
self.image_num += 1
|
||||||
feature = self.extract_feature(img, remove_background=False, debug_mode=False)
|
feature = self.extract_feature(img, remove_background=False, debug_mode=False)
|
||||||
feature = feature.reshape(1, -1)[:, [1, 2]]
|
feature = feature.reshape(1, -1)[:, FEATURE_INDEX]
|
||||||
if self.isCorrect:
|
if self.isCorrect:
|
||||||
feature = feature / (self.correct_color+1e-4)
|
feature = feature / (self.correct_color+1e-4)
|
||||||
pred_color = self.model.predict(feature)
|
pred_color = self.model.predict(feature)
|
||||||
@ -345,15 +345,15 @@ class WoodClass(object):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 初始化wood
|
# 初始化wood
|
||||||
wood = WoodClass(w=2048, h=12450, n=5000, debug_mode=False)
|
wood = WoodClass(w=4096, h=1200, n=3000, debug_mode=False)
|
||||||
print("色彩纯度控制量{}/{}".format(wood.k, wood.n))
|
print("色彩纯度控制量{}/{}".format(wood.k, wood.n))
|
||||||
wood.correct()
|
wood.correct()
|
||||||
# wood.load()
|
# wood.load()
|
||||||
# fit 相应的文件夹
|
# fit 相应的文件夹
|
||||||
wood.fit_pictures(data_path=r"C:\Users\Administrator.DESKTOP-K75IPPC\Desktop\data1108")
|
wood.fit_pictures(data_path=r"C:\Users\FEIJINTI\PycharmProjects\wood_color")
|
||||||
|
|
||||||
# 测试单张图片的预测,predict_mode=True表示导入本地的model, False为现场训练的
|
# 测试单张图片的预测,predict_mode=True表示导入本地的model, False为现场训练的
|
||||||
pic = cv2.imread(r"./data/dark/15.bmp")
|
pic = cv2.imread(r"./data/dark/rgb60.png")
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
wood_color = wood.predict(pic)
|
wood_color = wood.predict(pic)
|
||||||
|
|||||||
0
pics/TODO.png
Executable file → Normal file
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
0
pics/result.png
Executable file → Normal file
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
0
pics/从木板中提取色彩.png
Executable file → Normal file
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
0
pics/色彩分类.png
Executable file → Normal file
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
2
root_dir.py
Executable file → Normal file
@ -7,4 +7,4 @@ Created on Nov 3 21:18:26 2020
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
ROOT_DIR = r"C:\Users\Administrator.DESKTOP-K75IPPC\Desktop\wood-color"
|
ROOT_DIR = r"C:\Users\FEIJINTI\PycharmProjects\wood_color"
|
||||||