mirror of
https://github.com/NanjingForestryUniversity/supermachine-wood.git
synced 2025-11-08 10:13:53 +00:00
fix: 修改了排序的bug
This commit is contained in:
parent
8622db4a5b
commit
47b4274a41
@ -156,7 +156,7 @@ def main():
|
|||||||
# else:
|
# else:
|
||||||
# print('指令执行失败')
|
# print('指令执行失败')
|
||||||
elif cmd == 'KM':
|
elif cmd == 'KM':
|
||||||
model = r"C:\Users\FEIJINTI\OneDrive\PycharmProjects\wood_color\data\316"
|
model = r"E:\wood_color\data\318"
|
||||||
# model = "C:/Users/FEIJINTI/PycharmProjects/wood_color/models/model_2020-11-08_20-49.p"
|
# model = "C:/Users/FEIJINTI/PycharmProjects/wood_color/models/model_2020-11-08_20-49.p"
|
||||||
model = model.encode('ascii')
|
model = model.encode('ascii')
|
||||||
length = len(model) + 4
|
length = len(model) + 4
|
||||||
|
|||||||
@ -484,7 +484,9 @@ class WoodClass(object):
|
|||||||
sorted_cluster_indices = np.argsort([dark_mean[0], middle_mean[0], light_mean[0]])
|
sorted_cluster_indices = np.argsort([dark_mean[0], middle_mean[0], light_mean[0]])
|
||||||
labels = kmeans.labels_
|
labels = kmeans.labels_
|
||||||
for i in range(labels.shape[0]):
|
for i in range(labels.shape[0]):
|
||||||
labels[i] = sorted_cluster_indices[labels[i]]
|
indices = np.where(labels[i] == sorted_cluster_indices)
|
||||||
|
labels[i] = indices[0][0]
|
||||||
|
|
||||||
|
|
||||||
if plot_2d:
|
if plot_2d:
|
||||||
plt.figure()
|
plt.figure()
|
||||||
|
|||||||
@ -46,7 +46,7 @@ def process_cmd(cmd: str, data: any, connected_sock: socket.socket, detector: Wo
|
|||||||
detector.load(path=settings.model_path)
|
detector.load(path=settings.model_path)
|
||||||
response = simple_sock(connected_sock, cmd_type=cmd, result=result)
|
response = simple_sock(connected_sock, cmd_type=cmd, result=result)
|
||||||
elif cmd == 'KM':
|
elif cmd == 'KM':
|
||||||
x_data, y_data, labels, img_names = detector.get_kmeans_data(data, plot_2d=False)
|
x_data, y_data, labels, img_names = detector.get_kmeans_data(data, plot_2d=True)
|
||||||
result = detector.data_adjustments(x_data, y_data, labels, img_names)
|
result = detector.data_adjustments(x_data, y_data, labels, img_names)
|
||||||
result = ','.join([str(x) for x in result])
|
result = ','.join([str(x) for x in result])
|
||||||
response = simple_sock(connected_sock, cmd_type=cmd, result=result)
|
response = simple_sock(connected_sock, cmd_type=cmd, result=result)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user