Skip to content
Snippets Groups Projects
Commit 4d626291 authored by Franck Galpin's avatar Franck Galpin
Browse files

correct flake8 python errors

parent 04b77898
No related branches found
No related tags found
No related merge requests found
......@@ -543,7 +543,7 @@ class GeneratorDataPart(object):
"--ALF=0",
"--CCALF=0",
"--LMCSEnable=0",
"--NnlfOption=0"
"--NnlfOption=0",
]
if dict_picked["descr_stacked_up"]:
args_encoding.append(
......@@ -609,11 +609,17 @@ class GeneratorDataPart(object):
)
if rpr_scaling_ratio is not None:
if rpr_scaling_ratio != 2:
raise ValueError("`rpr_scaling_ratio` is not None and `rpr_scaling_ratio` is not equal to 2.")
raise ValueError(
"`rpr_scaling_ratio` is not None and `rpr_scaling_ratio` is not equal to 2."
)
if height_video % 8 * rpr_scaling_ratio != 0:
raise ValueError("`rpr_scaling_ratio` is not None and `height_video` is not divisible by 8*`rpr_scaling_ratio`.")
raise ValueError(
"`rpr_scaling_ratio` is not None and `height_video` is not divisible by 8*`rpr_scaling_ratio`."
)
if width_video % 8 * rpr_scaling_ratio != 0:
raise ValueError("`rpr_scaling_ratio` is not None and `width_video` is not divisible by 8*`rpr_scaling_ratio`.")
raise ValueError(
"`rpr_scaling_ratio` is not None and `width_video` is not divisible by 8*`rpr_scaling_ratio`."
)
args_encoding.append("--ScalingRatioHor={}".format(rpr_scaling_ratio))
args_encoding.append("--ScalingRatioVer={}".format(rpr_scaling_ratio))
subprocess.check_call(args_encoding, stdout=None, shell=False)
......@@ -673,7 +679,9 @@ class GeneratorDataPart(object):
os.remove(dict_picked["tuple_reference_writing"][1])
os.remove(dict_picked["tuple_reference_writing"][2])
os.remove(dict_picked["path_provided_2"])
numpy.testing.assert_equal(outs_intims[1], outs_intims[2], err_msg="Unexpected")
numpy.testing.assert_equal(
outs_intims[1], outs_intims[2], err_msg="Unexpected"
)
ch_single_or_pair_given = numpy.concatenate(
(outs_intims[0][:, :, 0:1], outs_intims[2][:, :, 0:1]), axis=2
)
......@@ -1334,7 +1342,7 @@ if __name__ == "__main__":
)
parser.add_argument(
"--is_dry_run",
help="if given, \"dry-run\" is activated. \"dry-run\" enables to run quickly the entire training of the neural network-based intra prediction mode on very little data, for the purpose of forecasting grid issues",
help='if given, "dry-run" is activated. "dry-run" enables to run quickly the entire training of the neural network-based intra prediction mode on very little data, for the purpose of forecasting grid issues',
action="store_true",
default=False,
)
......@@ -1407,7 +1415,7 @@ if __name__ == "__main__":
),
),
}
# In "dry-run, for an encoding via VTM-11-NNVC, QP belongs to {32, 42}.
if args.is_dry_run:
dict_picked["qps_int"] = numpy.array([32, 42])
......@@ -1421,7 +1429,15 @@ if __name__ == "__main__":
dict_supp = None
for pair_key in ((4, 4), (4, 8), (4, 16), (4, 32), (8, 8), (8, 16), (16, 16)):
if constants.IS_DATA_RAW_LARGE:
if pair_key in ((4, 16), (16, 4), (8, 16), (16, 8), (4, 32), (32, 4), (16, 16)):
if pair_key in (
(4, 16),
(16, 4),
(8, 16),
(16, 8),
(4, 32),
(32, 4),
(16, 16),
):
dict_hwt[pair_key] = 32768
else:
dict_hwt[pair_key] = 1024
......@@ -1431,7 +1447,9 @@ if __name__ == "__main__":
else:
dict_hwt[pair_key] = 131072
path_location = os.path.join(
args.path_to_directory_sets_training, "target_{0}_{1}".format(pair_key[0], pair_key[1]), tag_suffix_job
args.path_to_directory_sets_training,
"target_{0}_{1}".format(pair_key[0], pair_key[1]),
tag_suffix_job,
)
create_dconcurrently(path_location)
dict_in[pair_key] = os.path.join(path_location, "data.tfrecord")
......@@ -1439,7 +1457,11 @@ if __name__ == "__main__":
dict_supp[pair_key] = os.path.join(path_location, "ccs_tm_saved.npy")
with open(
os.path.join(
"results", "dispatching_paths_to_raw", "list_dicts_characteristics_own", "job_{}".format(args.index_job), "list_dicts_characteristics_own.pkl"
"results",
"dispatching_paths_to_raw",
"list_dicts_characteristics_own",
"job_{}".format(args.index_job),
"list_dicts_characteristics_own.pkl",
),
"rb",
) as file:
......
......@@ -36,16 +36,37 @@ import os
import subprocess
DICT_QUANTIZERS = {
(4, 4): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 18 10 -2 11 10 13 0 15 13 16 -1 17 0 19 17 20 -2 21 9",
(4, 8): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 17 10 -2 11 10 13 0 15 13 16 -2 17 0 19 18 20 -2 21 9",
(4, 16): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 17 10 -2 11 10 13 0 15 13 16 -2 17 0 19 18 20 -2 21 9",
(4, 32): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 15 10 -2 11 10 13 0 15 14 16 -2 17 0 19 18 20 -2 21 9",
(8, 8): "0 7 1 13 2 1 3 18 5 13 6 1 7 18 9 17 10 -2 11 10 13 0 15 14 16 -2 17 0 19 18 20 -2 21 9",
(8, 16): "0 7 1 13 2 1 3 18 5 12 6 1 7 18 9 15 10 -2 11 9 13 0 15 14 16 -2 17 0 19 18 20 -2 21 9",
(16, 16): "0 7 1 13 2 1 3 18 5 12 6 1 7 18 9 13 10 0 11 18 13 15 14 -2 15 10 17 0 19 13 20 -2 21 0 23 17 24 -2 25 9"
(
4,
4,
): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 18 10 -2 11 10 13 0 15 13 16 -1 17 0 19 17 20 -2 21 9",
(
4,
8,
): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 17 10 -2 11 10 13 0 15 13 16 -2 17 0 19 18 20 -2 21 9",
(
4,
16,
): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 17 10 -2 11 10 13 0 15 13 16 -2 17 0 19 18 20 -2 21 9",
(
4,
32,
): "0 7 1 14 2 0 3 18 5 12 6 2 7 18 9 15 10 -2 11 10 13 0 15 14 16 -2 17 0 19 18 20 -2 21 9",
(
8,
8,
): "0 7 1 13 2 1 3 18 5 13 6 1 7 18 9 17 10 -2 11 10 13 0 15 14 16 -2 17 0 19 18 20 -2 21 9",
(
8,
16,
): "0 7 1 13 2 1 3 18 5 12 6 1 7 18 9 15 10 -2 11 9 13 0 15 14 16 -2 17 0 19 18 20 -2 21 9",
(
16,
16,
): "0 7 1 13 2 1 3 18 5 12 6 1 7 18 9 13 10 0 11 18 13 15 14 -2 15 10 17 0 19 13 20 -2 21 0 23 17 24 -2 25 9",
}
if __name__ == '__main__':
if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog="Quantize SADL model in float into SADL model in 16-bit signed integer"
)
......@@ -62,7 +83,7 @@ if __name__ == '__main__':
parser.add_argument(
"path_to_exe_quantization_naive",
type=str,
help="Path to SADL naive quantizer executable"
help="Path to SADL naive quantizer executable",
)
parser.add_argument(
"height",
......@@ -75,13 +96,24 @@ if __name__ == '__main__':
help="Width of the blocks predicted by the neural network model at `args.path_to_input`",
)
args = parser.parse_args()
if not os.path.isfile(args.path_to_exe_quantization_naive):
raise OSError("The executable at `args.path_to_exe_quantization_naive` does not exist.")
raise OSError(
"The executable at `args.path_to_exe_quantization_naive` does not exist."
)
else:
if (args.height, args.width) in DICT_QUANTIZERS:
p = subprocess.Popen([args.path_to_exe_quantization_naive, args.path_to_input, args.path_to_output], stdin=subprocess.PIPE)
p = subprocess.Popen(
[
args.path_to_exe_quantization_naive,
args.path_to_input,
args.path_to_output,
],
stdin=subprocess.PIPE,
)
p.communicate(input=DICT_QUANTIZERS[(args.height, args.width)])
print("[INFO] Output model at {}".format(args.path_to_output))
else:
raise KeyError('`(args.height, args.width)` is not a key of `DICT_QUANTIZERS`.')
raise KeyError(
"`(args.height, args.width)` is not a key of `DICT_QUANTIZERS`."
)
......@@ -58,7 +58,6 @@ IS_LOSS_VISUALIZED = False
if IS_LOSS_VISUALIZED:
import matplotlib
try:
import PyQt5
matplotlib.use('Qt5Agg')
except ImportError:
matplotlib.use('Agg')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment