예제 #1
0
def advanced_debugging():
    config = get_config()

    st.sidebar.markdown("# Advanced Debugging")
    if st.sidebar.button("Compare Baseline to Output Directory"):
        """
        ## Comparing Results to Baseline
        """

        baseline_directory = pathlib.Path(
            config["debug"]["baseline_directory"]).resolve()

        png_baseline_directory = baseline_directory.joinpath("png")

        baseline_png_paths = [
            path for path in (png_baseline_directory.rglob("*"))
            if path.is_file()
        ]

        relative_png_paths = [
            path.relative_to(png_baseline_directory)
            for path in baseline_png_paths
        ]

        output_dir = pathlib.Path(config["output"]["png_directory"]).resolve()

        evaluation_png_paths = [
            output_dir.joinpath(path) for path in relative_png_paths
        ]

        for baseline, evaluation in zip(baseline_png_paths,
                                        evaluation_png_paths):

            f"### {baseline.parent.name}/{baseline.name}"

            f"`{baseline}`\n\n**vs**\n\n`{evaluation}`"

            baseline_image = imageio.imread(baseline)

            try:
                evaluation_image = imageio.imread(evaluation)
            except FileNotFoundError as e:
                """
                #### File was not found
                """
                st.write(e)
                f"""
                For debugging purposes, here are all the files that
                were found within {str(output_dir)}
                """

                [str(path) for path in output_dir.rglob("*") if path.is_file()]

                return

            agree = np.allclose(baseline_image, evaluation_image)
            f"Images Agree: `{agree}`"
예제 #2
0
def imread(input_filepath):
    input_filepath = pathlib.Path(input_filepath)

    with tempfile.TemporaryDirectory() as temp_dir:
        temp_dir_path = pathlib.Path(temp_dir)
        temp_path = temp_dir_path.joinpath(input_filepath.name)

        convert_lossless_jpeg(input_filepath, output_filepath=temp_path)

        im = imageio.imread(temp_path)

    return im
예제 #3
0
파일: iview.py 프로젝트: lc52520/pymedphys
def iview_image_transform_from_path(image_path):
    img = imageio.imread(image_path)

    return iview_image_transform(img)