Commit a4c6de4a authored by Alexander Gehrke's avatar Alexander Gehrke

Clean up and fix weak warnings

parent 067e7e61
import argparse
from ocr4all_pixel_classifier.lib.dataset import list_dataset, single_split, create_splits
from random import seed
import json
......@@ -49,6 +48,7 @@ def main():
args = parser.parse_args()
from random import seed
seed(args.seed)
data_files = list_dataset(args.dataset_path, args.xheight,
......@@ -64,17 +64,17 @@ def main():
train, test = split
write_json(args.output_file.format(i), args.dataset_path, args.seed, train, test, [])
else:
train, test, eval = single_split(args.n_train, args.n_test, args.n_eval, data_files)
write_json(args.output_file, args.dataset_path, args.seed, train, test, eval)
train, test, evaluation = single_split(args.n_train, args.n_test, args.n_eval, data_files)
write_json(args.output_file, args.dataset_path, args.seed, train, test, evaluation)
def write_json(output_file, dataset_path, seed, train, test, eval):
def write_json(output_file, dataset_path, seed, train, test, evaluation):
content = json.dumps({
"seed": seed,
"dataset_path": dataset_path,
"train": train,
"test": test,
"eval": eval,
"eval": evaluation,
}, indent=4)
with open(output_file, "w") as f:
f.write(content)
......
......@@ -12,8 +12,7 @@ def main():
args = parser.parse_args()
for imap in args.vars:
map = ColorMap.load(imap)
for k, v in map.mapping.items():
for k, v in ColorMap.load(imap).mapping.items():
print(f"\x1b[48;2;{k[0]};{k[1]};{k[2]}m \x1b[0m \x1b[38;2;{k[0]};{k[1]};{k[2]}m{v}\x1b[0m\n")
......
......@@ -67,9 +67,9 @@ def main():
def relpaths(basedir: str, files: List[str]) -> List[str]:
return [x if x[0] == "/" else path.join(basedir, x) for x in files]
def is_valid_splitfile(json):
def is_valid_splitfile(jsondata):
for category in ["train", "test", "eval"]:
if type(json[category]) == list and len(json[category]) > 0 and type(json[category][0]) != str:
if type(jsondata[category]) == list and len(jsondata[category]) > 0 and type(jsondata[category][0]) != str:
return False
return True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment