output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] IndexError: invalid index to scalar variable.
# This error occured after an upgrade of cv from version 3 to version 4.
#remedy change layer_names[i[0] - 1] to layer_names[i-1] as below:
outputlayers = [layer_names[i-1] for i in net.getUnconnectedOutLayers()]