diff --git a/.github/workflows/layout_unreadability.yaml b/.github/workflows/layout_unreadability.yaml index 88020f9..aee8334 100644 --- a/.github/workflows/layout_unreadability.yaml +++ b/.github/workflows/layout_unreadability.yaml @@ -51,20 +51,5 @@ jobs: HF_EMAIL: ${{ secrets.HF_EMAIL }} SCRIPTS_DIR: ${{ env.SRC_DIR }}/scripts run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + makefile_path=${SRC_DIR}/Makefile + make -f ${makefile_path} deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/.gitignore b/.gitignore index 04c3875..5ec8f8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Created by https://www.toptal.com/developers/gitignore/api/python # Edit at https://www.toptal.com/developers/gitignore?templates=python +PKU_PosterLayout_all + ### Python ### # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/README.md b/README.md index b7c8a77..123d004 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,14 @@ A collection of metrics to evaluate layout generation that can be easily used in | [![Alignment](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_alignment.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_alignment.yaml) | [`creative-graphic-design/layout-alignment`](https://huggingface.co/spaces/creative-graphic-design/layout-alignment) | [[Lee+ ECCV'20](https://arxiv.org/abs/1912.09421)], [[Li+ TVCG'21](https://arxiv.org/abs/2009.05284)], [[Kikuchi+ ACMMM'21](https://arxiv.org/abs/2108.00871)] | | [![Overlap](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml) | [`creative-graphic-design/layout-overlap`](https://huggingface.co/spaces/creative-graphic-design/layout-overlap) | [[Li+ ICLR'19](https://arxiv.org/abs/1901.06767)], [[Li+ TVCG'21](https://arxiv.org/abs/2009.05284)], [[Kikuchi+ ACMMM'21](https://arxiv.org/abs/2108.00871)] | | [![Validity](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_validity.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_validity.yaml) | | [[Hsu+ CVPR'23](https://arxiv.org/abs/2303.15937)] | - -# How to use +| [![Occlusion](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_occlusion.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_occlusion.yaml) | | | +| [![Overlap](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml) | | | +| [![Overlay](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlay.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlay.yaml) | | | +| [![Underlay Effectiveness](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_underlay_effectivness.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_underlay_effectivness.yaml) | | | +| [![Unreadability](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_unreadability.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_unreadability.yaml) | | | +| [![Non-Alignment](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_non_alignment.yaml/badge.svg)](https://github.com/creative-graphic-design/huggingface-evaluate_layout-metrics/actions/workflows/layout_non_alignment.yaml) | | | + +# Usage - Install [`evaluate`](https://huggingface.co/docs/evaluate/index) library diff --git a/layout_alignment/README.md b/metrics/layout_alignment/README.md similarity index 100% rename from layout_alignment/README.md rename to metrics/layout_alignment/README.md diff --git a/layout_alignment/layout-alignment.py b/metrics/layout_alignment/layout-alignment.py similarity index 100% rename from layout_alignment/layout-alignment.py rename to metrics/layout_alignment/layout-alignment.py diff --git a/layout_average_iou/README.md b/metrics/layout_average_iou/README.md similarity index 100% rename from layout_average_iou/README.md rename to metrics/layout_average_iou/README.md diff --git a/layout_average_iou/layout-average-iou.py b/metrics/layout_average_iou/layout-average-iou.py similarity index 100% rename from layout_average_iou/layout-average-iou.py rename to metrics/layout_average_iou/layout-average-iou.py diff --git a/layout_generative_model_scores/README.md b/metrics/layout_generative_model_scores/README.md similarity index 100% rename from layout_generative_model_scores/README.md rename to metrics/layout_generative_model_scores/README.md diff --git a/layout_generative_model_scores/layout-generative-model-scores.py b/metrics/layout_generative_model_scores/layout-generative-model-scores.py similarity index 100% rename from layout_generative_model_scores/layout-generative-model-scores.py rename to metrics/layout_generative_model_scores/layout-generative-model-scores.py diff --git a/layout_maximum_iou/README.md b/metrics/layout_maximum_iou/README.md similarity index 100% rename from layout_maximum_iou/README.md rename to metrics/layout_maximum_iou/README.md diff --git a/layout_maximum_iou/layout-maximum-iou.py b/metrics/layout_maximum_iou/layout-maximum-iou.py similarity index 100% rename from layout_maximum_iou/layout-maximum-iou.py rename to metrics/layout_maximum_iou/layout-maximum-iou.py diff --git a/layout_non_alignment/README.md b/metrics/layout_non_alignment/README.md similarity index 100% rename from layout_non_alignment/README.md rename to metrics/layout_non_alignment/README.md diff --git a/layout_non_alignment/layout-non-alignment.py b/metrics/layout_non_alignment/layout-non-alignment.py similarity index 100% rename from layout_non_alignment/layout-non-alignment.py rename to metrics/layout_non_alignment/layout-non-alignment.py diff --git a/layout_occlusion/README.md b/metrics/layout_occlusion/README.md similarity index 100% rename from layout_occlusion/README.md rename to metrics/layout_occlusion/README.md diff --git a/layout_occlusion/layout-occlusion.py b/metrics/layout_occlusion/layout-occlusion.py similarity index 100% rename from layout_occlusion/layout-occlusion.py rename to metrics/layout_occlusion/layout-occlusion.py diff --git a/layout_overlap/README.md b/metrics/layout_overlap/README.md similarity index 100% rename from layout_overlap/README.md rename to metrics/layout_overlap/README.md diff --git a/layout_overlap/__init__.py b/metrics/layout_overlap/__init__.py similarity index 100% rename from layout_overlap/__init__.py rename to metrics/layout_overlap/__init__.py diff --git a/layout_overlap/layout-overlap.py b/metrics/layout_overlap/layout-overlap.py similarity index 100% rename from layout_overlap/layout-overlap.py rename to metrics/layout_overlap/layout-overlap.py diff --git a/layout_overlay/README.md b/metrics/layout_overlay/README.md similarity index 100% rename from layout_overlay/README.md rename to metrics/layout_overlay/README.md diff --git a/layout_overlay/layout-overlay.py b/metrics/layout_overlay/layout-overlay.py similarity index 100% rename from layout_overlay/layout-overlay.py rename to metrics/layout_overlay/layout-overlay.py diff --git a/layout_underlay_effectiveness/README.md b/metrics/layout_underlay_effectiveness/README.md similarity index 100% rename from layout_underlay_effectiveness/README.md rename to metrics/layout_underlay_effectiveness/README.md diff --git a/layout_underlay_effectiveness/layout-underlay-effectiveness.py b/metrics/layout_underlay_effectiveness/layout-underlay-effectiveness.py similarity index 100% rename from layout_underlay_effectiveness/layout-underlay-effectiveness.py rename to metrics/layout_underlay_effectiveness/layout-underlay-effectiveness.py diff --git a/layout_unreadability/README.md b/metrics/layout_unreadability/README.md similarity index 100% rename from layout_unreadability/README.md rename to metrics/layout_unreadability/README.md diff --git a/layout_unreadability/layout-unreadability.py b/metrics/layout_unreadability/layout-unreadability.py similarity index 100% rename from layout_unreadability/layout-unreadability.py rename to metrics/layout_unreadability/layout-unreadability.py diff --git a/layout_utility/README.md b/metrics/layout_utility/README.md similarity index 100% rename from layout_utility/README.md rename to metrics/layout_utility/README.md diff --git a/layout_utility/layout-utility.py b/metrics/layout_utility/layout-utility.py similarity index 100% rename from layout_utility/layout-utility.py rename to metrics/layout_utility/layout-utility.py diff --git a/layout_validity/README.md b/metrics/layout_validity/README.md similarity index 100% rename from layout_validity/README.md rename to metrics/layout_validity/README.md diff --git a/layout_validity/layout-validity.py b/metrics/layout_validity/layout-validity.py similarity index 100% rename from layout_validity/layout-validity.py rename to metrics/layout_validity/layout-validity.py diff --git a/scripts/push_to_hub.sh b/scripts/push_to_hub.sh index 6b4d4d5..42747bd 100755 --- a/scripts/push_to_hub.sh +++ b/scripts/push_to_hub.sh @@ -4,10 +4,10 @@ set -eux function main() { script_name=${REPO_NAME}.py - + # Copy the script to the destination directory - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${script_name} ${DST_DIR}/${script_name} + cp ${SRC_DIR}/metrics/${DIR_NAME}/README.md ${DST_DIR}/README.md + cp ${SRC_DIR}/metrics/${DIR_NAME}/${script_name} ${DST_DIR}/${script_name} # Set configuration for git git -C ${DST_DIR} config user.name ${HF_USERNAME} diff --git a/tests/conftest.py b/tests/conftest.py index c7b846e..e48dded 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,11 @@ import torch +@pytest.fixture +def metrics_dir() -> pathlib.Path: + return pathlib.Path(__file__).parents[1] / "metrics" + + @pytest.fixture def test_fixture_dir() -> pathlib.Path: return pathlib.Path(__file__).parents[1] / "test_fixtures" diff --git a/tests/layout_alignment_test.py b/tests/layout_alignment_test.py index cee0168..dce228b 100644 --- a/tests/layout_alignment_test.py +++ b/tests/layout_alignment_test.py @@ -10,12 +10,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_alignment" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_alignment" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-alignment.py") diff --git a/tests/layout_average_iou_test.py b/tests/layout_average_iou_test.py index 330a454..39b3028 100644 --- a/tests/layout_average_iou_test.py +++ b/tests/layout_average_iou_test.py @@ -11,12 +11,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_average_iou" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_average_iou" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-average-iou.py") diff --git a/tests/layout_generative_model_scores_test.py b/tests/layout_generative_model_scores_test.py index 0aba99d..426e97f 100644 --- a/tests/layout_generative_model_scores_test.py +++ b/tests/layout_generative_model_scores_test.py @@ -9,12 +9,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_generative_model_scores" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_generative_model_scores" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-generative-model-scores.py") diff --git a/tests/layout_maximum_iou_test.py b/tests/layout_maximum_iou_test.py index a066c65..9cdbd53 100644 --- a/tests/layout_maximum_iou_test.py +++ b/tests/layout_maximum_iou_test.py @@ -10,12 +10,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_maximum_iou" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_maximum_iou" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-maximum-iou.py") diff --git a/tests/layout_non_alignment_test.py b/tests/layout_non_alignment_test.py index c6b1064..48082a8 100644 --- a/tests/layout_non_alignment_test.py +++ b/tests/layout_non_alignment_test.py @@ -1,4 +1,5 @@ import os +import pathlib import evaluate import pytest @@ -6,12 +7,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_non_alignment" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_non_alignment" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-non-alignment.py") diff --git a/tests/layout_occulusion_test.py b/tests/layout_occulusion_test.py index fa5c928..a1c94c1 100644 --- a/tests/layout_occulusion_test.py +++ b/tests/layout_occulusion_test.py @@ -8,12 +8,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_occlusion" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_occlusion" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-occlusion.py") diff --git a/tests/layout_overlap_test.py b/tests/layout_overlap_test.py index 83e99a5..8fc0dd8 100644 --- a/tests/layout_overlap_test.py +++ b/tests/layout_overlap_test.py @@ -10,12 +10,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_overlap" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_overlap" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-overlap.py") diff --git a/tests/layout_overlay_test.py b/tests/layout_overlay_test.py index 47b3791..8b3af86 100644 --- a/tests/layout_overlay_test.py +++ b/tests/layout_overlay_test.py @@ -1,4 +1,5 @@ import os +import pathlib import evaluate import pytest @@ -6,12 +7,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_overlay" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_overlay" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-overlay.py") diff --git a/tests/layout_underlay_effectiveness_test.py b/tests/layout_underlay_effectiveness_test.py index 4980678..48722f0 100644 --- a/tests/layout_underlay_effectiveness_test.py +++ b/tests/layout_underlay_effectiveness_test.py @@ -1,4 +1,5 @@ import os +import pathlib import evaluate import pytest @@ -6,8 +7,8 @@ @pytest.fixture -def base_dir() -> str: - return "layout_underlay_effectiveness" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_underlay_effectiveness" @pytest.fixture diff --git a/tests/layout_unreadability_test.py b/tests/layout_unreadability_test.py index 3cb5d15..4eca16a 100644 --- a/tests/layout_unreadability_test.py +++ b/tests/layout_unreadability_test.py @@ -8,12 +8,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_unreadability" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_unreadability" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-unreadability.py") diff --git a/tests/layout_utility_test.py b/tests/layout_utility_test.py index 8edf5f4..4948514 100644 --- a/tests/layout_utility_test.py +++ b/tests/layout_utility_test.py @@ -8,12 +8,12 @@ @pytest.fixture -def base_dir() -> str: - return "layout_utility" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_utility" @pytest.fixture -def metric_path(base_dir: str) -> str: +def metric_path(base_dir: pathlib.Path) -> str: return os.path.join(base_dir, "layout-utility.py") diff --git a/tests/layout_validity_test.py b/tests/layout_validity_test.py index acc10db..2c18ec9 100644 --- a/tests/layout_validity_test.py +++ b/tests/layout_validity_test.py @@ -1,4 +1,5 @@ import os +import pathlib import evaluate import pytest @@ -6,8 +7,8 @@ @pytest.fixture -def base_dir() -> str: - return "layout_validity" +def base_dir(metrics_dir: pathlib.Path) -> pathlib.Path: + return metrics_dir / "layout_validity" @pytest.fixture