コード例 #1
0
def test_anno_image_input_cli_image_and_json(capsys, img_file, json_file):
    test_anno_image_input = AnnotatedImageInput()

    test_args = ["--image", img_file, "--annotations", json_file]
    test_anno_image_input.handle_cli(test_args, predict_image_and_json)
    out, _ = capsys.readouterr()

    assert out.strip() == "((10, 10, 3), 'kaith')"
コード例 #2
0
def test_anno_image_input_cli_image_only(capsys, img_file):
    test_anno_image_input = AnnotatedImageInput()

    test_args = ["--image", img_file]
    test_anno_image_input.handle_cli(test_args, predict_image_only)
    out, _ = capsys.readouterr()

    assert out.strip() == "(10, 10, 3)"
コード例 #3
0
def test_anno_image_input_cli_relative_paths(capsys, img_file, json_file):
    test_anno_image_input = AnnotatedImageInput()

    try:
        # This fails on Windows if our file is on a different drive
        relative_image_path = os.path.relpath(img_file)
        relative_annotation_path = os.path.relpath(json_file)
    except ValueError:
        # Switch to the drive with the files image on it, and try again
        os.chdir(img_file[:2])
        relative_image_path = os.path.relpath(img_file)
        relative_annotation_path = os.path.relpath(json_file)

    test_args = [
        "--image",
        relative_image_path,
        "--annotations",
        relative_annotation_path,
    ]
    test_anno_image_input.handle_cli(test_args, predict_image_and_json)
    out, _ = capsys.readouterr()

    assert out.strip() == "((10, 10, 3), 'kaith')"