generated from LufsX/Experiment-kNN
This commit is contained in:
+3
-2
@@ -108,8 +108,9 @@ def img_to_vector(filename):
|
||||
- np.array: 二值图像向量。
|
||||
"""
|
||||
with open(filename, 'r') as f:
|
||||
return np.array([int(char) for char in f.read().strip()]).reshape(1, -1)
|
||||
|
||||
lines = f.readlines()
|
||||
vector = np.array([int(char) for line in lines for char in line.strip() if char.isdigit()])
|
||||
return vector.reshape(1, -1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 以下代码可用于测试,可自行随意修改
|
||||
|
||||
Reference in New Issue
Block a user