Updates
This commit is contained in:
47
rpi/training/utils/verifiy.py
Normal file
47
rpi/training/utils/verifiy.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import os
|
||||
|
||||
if __name__ == "__main__":
|
||||
trg_dir = "../datasets/pieces/unified/train/labels"
|
||||
src_dir = "../datasets/pieces/khalid/train/labels"
|
||||
|
||||
trg_labels = [
|
||||
'w_pawn','w_knight','w_bishop','w_rook','w_queen','w_king',
|
||||
'b_pawn','b_knight','b_bishop','b_rook','b_queen','b_king'
|
||||
]
|
||||
|
||||
src_labels = [
|
||||
'b_bishop', 'b_king', 'b_knight', 'b_queen', 'b_rook', 'b_pawn',
|
||||
'w_bishop', 'w_king', 'w_knight', 'w_queen', 'w_rook', 'w_pawn'
|
||||
]
|
||||
|
||||
trg_files = os.listdir(trg_dir)
|
||||
src_files = os.listdir(src_dir)
|
||||
|
||||
for src_file in src_files:
|
||||
trg_file = os.path.abspath(os.path.join(trg_dir, src_file))
|
||||
src_file = os.path.abspath(os.path.join(src_dir, src_file))
|
||||
|
||||
trg_lines = []
|
||||
src_lines = []
|
||||
|
||||
with open(src_file, "r") as f:
|
||||
src_lines = f.readlines().copy()
|
||||
|
||||
with open(trg_file, "r") as f:
|
||||
trg_lines = f.readlines().copy()
|
||||
|
||||
for i in range(0, len(trg_lines)):
|
||||
trg_line = trg_lines[i]
|
||||
src_line = src_lines[i]
|
||||
|
||||
trg_label_index = int(trg_line.strip().split(" ")[0])
|
||||
src_label_index = int(src_line.strip().split(" ")[0])
|
||||
|
||||
trg_label_value = trg_labels[trg_label_index]
|
||||
src_label_value = src_labels[src_label_index]
|
||||
|
||||
if trg_label_value != src_label_value :
|
||||
print(f"Error detected in {trg_file} at line {i}.\n"
|
||||
f"==> Index {trg_label_index} points to {trg_label_value} instead of {src_label_index}:{src_label_value}")
|
||||
|
||||
print("Detection terminated.")
|
||||
Reference in New Issue
Block a user