添加了qt传输模型名称的功能

This commit is contained in:
FEIJINTI 2023-03-06 15:49:00 +08:00
parent b12bb52a6d
commit 363443ae94
2 changed files with 7 additions and 3 deletions

View File

@ -97,7 +97,7 @@ class WoodClass(object):
sample = cv2.resize(x, (self.ww, self.hh))
return sample
def fit_pictures(self, data_path=ROOT_DIR):
def fit_pictures(self, data_path=ROOT_DIR, file_name=None):
"""
根据给出的data_path 进行 fit.如果没有给出data目录那么将会使用当前文件夹
:param data_path:
@ -110,7 +110,7 @@ class WoodClass(object):
x, y = result
score = self.fit(x, y)
print('model score', score)
model_name = self.save()
model_name = self.save(file_name)
return model_name
def fit(self, x, y, test_size=0.1):

View File

@ -33,8 +33,12 @@ def process_cmd(cmd: str, data: any, connected_sock: socket.socket, detector: Wo
response = simple_sock(connected_sock, cmd_type=cmd, result=wood_color)
elif cmd == 'TR':
detector = WoodClass(w=4096, h=1200, n=3000, debug_mode=False)
model_name = None
if "/n" in data:
data, model_name = data.split("/n", 1)
model_name = model_name + ".p"
settings.data_path = data
settings.model_path = ROOT_DIR / 'models' / detector.fit_pictures(data_path=settings.data_path)
settings.model_path = ROOT_DIR / 'models' / detector.fit_pictures(data_path=settings.data_path, file_name=model_name)
response = simple_sock(connected_sock, cmd_type=cmd)
elif cmd == 'MD':
settings.model_path = data