def test_should_process_example_with_args( self, example_config_filename: str, additional_args: List[str], get_image_output_sink_for_path_mock: GetCapturingOutputSink): config_file = Path(EXAMPLE_CONFIG_DIR) / example_config_filename main(['start', '--config-file=%s' % config_file] + additional_args) sink = get_image_output_sink_for_path_mock.last_sink assert len(sink.images) > 0
def test_should_copy_source_to_target_image(self, temp_dir: Path): output_path = temp_dir / 'output.png' config_file = temp_dir / 'config.yml' config_file.write_text(''' layers: - id: in input_path: {input_path} - id: out output_path: {output_path} '''.format(input_path=_quote_path(EXAMPLE_IMAGE_URL), output_path=_quote_path(output_path))) main(['start', '--config-file=%s' % config_file]) image = _load_image(output_path) height, width, *_ = image.shape assert width > 0 assert height > 0
def test_should_be_able_to_replace_input_and_output_path( self, temp_dir: Path): output_path = temp_dir / 'output.png' config_file = temp_dir / 'config.yml' config_file.write_text(''' layers: - id: in input_path: "dummy" - id: out output_path: "dummy" ''') main([ 'start', '--config-file=%s' % config_file, '--set', 'in.input_path=%s' % EXAMPLE_IMAGE_URL, '--set', 'out.output_path=%s' % output_path ]) image = _load_image(output_path) height, width, *_ = image.shape assert width > 0 assert height > 0
def test_should_copy_to_multiple_outputs(self, temp_dir: Path): output_path_1 = temp_dir / 'output_1.png' output_path_2 = temp_dir / 'output_2.png' config_file = temp_dir / 'config.yml' config_file.write_text(''' layers: - id: in input_path: {input_path} width: 320 height: 200 - id: out_1 output_path: {output_path_1} - id: out_2 output_path: {output_path_2} '''.format(input_path=_quote_path(EXAMPLE_IMAGE_URL), output_path_1=_quote_path(output_path_1), output_path_2=_quote_path(output_path_2))) main(['start', '--config-file=%s' % config_file]) for output_path in [output_path_1, output_path_2]: image = _load_image(output_path) height, width, *_ = image.shape assert (width, height) == (320, 200)
import logging from layered_vision.cli import main if __name__ == '__main__': logging.basicConfig(level='INFO') main()