1
0
mirror of https://github.com/2martens/uni.git synced 2026-05-06 11:26:25 +02:00
Files
uni/ccv/saliency/tools/batch_saliency.py
2017-06-05 11:39:53 +02:00

28 lines
1.0 KiB
Python

import argparse
import os
import subprocess
def batch():
"""
Performs a batch call to the saliency system.
"""
parser = argparse.ArgumentParser(description="Calls the saliency system")
parser.add_argument("input", metavar="input", type=str, help="The directory of the input images.")
parser.add_argument("output", metavar="output", type=str, help="The directory of the saliency maps.")
parser.add_argument("saliency", metavar="saliency", type=str, help="The path to the saliency tool.")
args = parser.parse_args()
input_dir = os.fsencode(args.input)
for file in os.listdir(input_dir):
filename = os.fsdecode(file)
base_filename, ext = os.path.splitext(filename)
input_filename = os.path.join(args.input, filename)
output_filename = os.path.join(args.output, base_filename + "_saliency.png")
subprocess.run([args.saliency, input_filename, output_filename, "1"], stderr=subprocess.PIPE, check=True)
if __name__ == "__main__":
batch()