Skip to content

Commit

Permalink
update README.md (#13)
Browse files Browse the repository at this point in the history
* update README.md

* update
  • Loading branch information
shunk031 authored Jun 23, 2024
1 parent fb8f67e commit 7d699a4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions layout_alignment/layout-alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
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,))
>>> metric.add(bbox=bbox, mask=mask)
>>> 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))
Expand Down
4 changes: 2 additions & 2 deletions layout_average_iou/layout-average-iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 = [
>>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
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)
>>> metric.add(feats_real=feats_real, feats_fake=feats_fake)
>>> 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)
Expand Down
4 changes: 2 additions & 2 deletions layout_maximum_iou/layout-maximum-iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 = [
>>> {
Expand Down

0 comments on commit 7d699a4

Please sign in to comment.