From 7d699a4c61838f1596e1cfa9c53f636c1c4126e5 Mon Sep 17 00:00:00 2001 From: Shunsuke KITADA Date: Sun, 23 Jun 2024 22:30:35 +0900 Subject: [PATCH] update README.md (#13) * update README.md * update --- README.md | 19 ++++++++++--------- layout_alignment/layout-alignment.py | 4 ++-- layout_average_iou/layout-average-iou.py | 4 ++-- .../layout-generative-model-scores.py | 4 ++-- layout_maximum_iou/layout-maximum-iou.py | 4 ++-- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index fc3dbcc..7f3c456 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ A collection of metrics to evaluate layout generation that can be easily used in | 📊 Metric | 🤗 Space | |:---------:|:---------:| -| [![FID](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_generative_model_scores.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_generative_model_scores.yaml) | [`pytorch-layout-generation/layout-generative-model-scores`](https://huggingface.co/spaces/pytorch-layout-generation/layout-generative-model-scores) | -| [![Max. IoU](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_maximum_iou.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_maximum_iou.yaml) | [`pytorch-layout-generation/layout-maximum-iou`](https://huggingface.co/spaces/pytorch-layout-generation/layout-maximum-iou) | -| [![Avg. IoU](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_average_iou.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_average_iou.yaml) | [`pytorch-layout-generation/layout-average-iou`](https://huggingface.co/spaces/pytorch-layout-generation/layout-average-iou) | -| [![Alignment](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_alignment.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_alignment.yaml) | [`pytorch-layout-generation/layout-alignment`](https://huggingface.co/spaces/pytorch-layout-generation/layout-alignment) | -| [![Overlap](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml) | [`pytorch-layout-generation/layout-overlap`](https://huggingface.co/spaces/pytorch-layout-generation/layout-overlap) | +| [![FID](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_generative_model_scores.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_generative_model_scores.yaml) | [`creative-graphic-design/layout-generative-model-scores`](https://huggingface.co/spaces/creative-graphic-design/layout-generative-model-scores) | +| [![Max. IoU](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_maximum_iou.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_maximum_iou.yaml) | [`creative-graphic-design/layout-maximum-iou`](https://huggingface.co/spaces/creative-graphic-design/layout-maximum-iou) | +| [![Avg. IoU](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_average_iou.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_average_iou.yaml) | [`creative-graphic-design/layout-average-iou`](https://huggingface.co/spaces/creative-graphic-design/layout-average-iou) | +| [![Alignment](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_alignment.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_alignment.yaml) | [`creative-graphic-design/layout-alignment`](https://huggingface.co/spaces/creative-graphic-design/layout-alignment) | +| [![Overlap](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml/badge.svg)](https://github.com/shunk031/huggingface-evaluate_layout-metrics/actions/workflows/layout_overlap.yaml) | [`creative-graphic-design/layout-overlap`](https://huggingface.co/spaces/creative-graphic-design/layout-overlap) | # How to use @@ -27,13 +27,14 @@ pip install evaluate import evaluate import numpy as np -# Load the evaluation metric named "pytorch-layout-generation/layout-alignment" -alignment_score = evaluate.load("pytorch-layout-generation/layout-alignment") +# Load the evaluation metric named "creative-graphic-design/layout-alignment" +alignment_score = evaluate.load("creative-graphic-design/layout-alignment") # `batch_bbox` is a tensor representing (batch_size, max_num_elements, coordinates) -# and `batch_mask` is a tensor representing (batch_size, max_num_elements). +# and `batch_mask` is a boolean tensor representing (batch_size, max_num_elements). batch_bbox = np.random.rand(512, 25, 4) -batch_mask = np.random.rand(512, 25) +# Note that padded fields will be set to `False` +batch_mask = np.full((512, 25), fill_value=True) # Add the batch of bboxes and masks to the metric alignment_score.add_batch(batch_bbox=batch_bbox, batch_mask=batch_mask) diff --git a/layout_alignment/layout-alignment.py b/layout_alignment/layout-alignment.py index 0b9b666..e28e246 100644 --- a/layout_alignment/layout-alignment.py +++ b/layout_alignment/layout-alignment.py @@ -20,7 +20,7 @@ Examples: Example 1: Single processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-alignment") + >>> metric = evaluate.load("creative-graphic-design/layout-alignment") >>> model_max_length, num_coordinates = 25, 4 >>> bbox = np.random.rand(model_max_length, num_coordinates) >>> mask = np.random.choice(a=[True, False], size=(model_max_length,)) @@ -28,7 +28,7 @@ >>> print(metric.compute()) Example 2: Batch processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-alignment") + >>> metric = evaluate.load("creative-graphic-design/layout-alignment") >>> batch_size, model_max_length, num_coordinates = 512, 25, 4 >>> batch_bbox = np.random.rand(batch_size, model_max_length, num_coordinates) >>> batch_mask = np.random.choice(a=[True, False], size=(batch_size, model_max_length)) diff --git a/layout_average_iou/layout-average-iou.py b/layout_average_iou/layout-average-iou.py index e8c492f..627380e 100644 --- a/layout_average_iou/layout-average-iou.py +++ b/layout_average_iou/layout-average-iou.py @@ -19,7 +19,7 @@ Examples: Example 1: Single processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-average-iou") + >>> metric = evaluate.load("creative-graphic-design/layout-average-iou") >>> num_samples, num_categories = 24, 4 >>> layout = { >>> "bboxes": np.random.rand(num_samples, num_categories), @@ -29,7 +29,7 @@ >>> print(metric.compute()) Example 2: Batch processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-average-iou") + >>> metric = evaluate.load("creative-graphic-design/layout-average-iou") >>> batch_size, num_samples, num_categories = 512, 24, 4 >>> layouts = [ >>> { diff --git a/layout_generative_model_scores/layout-generative-model-scores.py b/layout_generative_model_scores/layout-generative-model-scores.py index e8ab5af..696bc38 100644 --- a/layout_generative_model_scores/layout-generative-model-scores.py +++ b/layout_generative_model_scores/layout-generative-model-scores.py @@ -22,7 +22,7 @@ Examples: Example 1: Single processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-generative-model-scores") + >>> metric = evaluate.load("creative-graphic-design/layout-generative-model-scores") >> feat_size = 256 >>> feats_real = np.random.rand(feat_size) >>> feats_fake = np.random.rand(feat_size) @@ -30,7 +30,7 @@ >>> print(metric.compute()) Example 2: Batch processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-generative-model-scores") + >>> metric = evaluate.load("creative-graphic-design/layout-generative-model-scores") >>> batch_size, feat_size = 512, 256 >>> feats_real = np.random.rand(batch_size, feat_size) >>> feats_fake = np.random.rand(batch_size, feat_size) diff --git a/layout_maximum_iou/layout-maximum-iou.py b/layout_maximum_iou/layout-maximum-iou.py index eaf8170..0333896 100644 --- a/layout_maximum_iou/layout-maximum-iou.py +++ b/layout_maximum_iou/layout-maximum-iou.py @@ -29,7 +29,7 @@ class Layout(TypedDict): Examples: Example 1: Single processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-maximum-iou") + >>> metric = evaluate.load("creative-graphic-design/layout-maximum-iou") >>> num_samples, num_categories = 24, 4 >>> layout1 = { >>> "bboxes": np.random.rand(num_samples, num_categories), @@ -43,7 +43,7 @@ class Layout(TypedDict): >>> print(metric.compute()) Example 2: Batch processing - >>> metric = evaluate.load("pytorch-layout-generation/layout-maximum-iou") + >>> metric = evaluate.load("creative-graphic-design/layout-maximum-iou") >>> batch_size, num_samples, num_categories = 512, 24, 4 >>> layouts1 = [ >>> {