Skip to content

[FEATURE] Add ImageReward Metric #133

@begumcig

Description

@begumcig

✨ What You’ll Do

Adding more metrics makes Pruna’s evaluations way more insightful, so we’re super excited to welcome ImageReward (paper) (repo) into our metric lineup!


🛠️ Dependency

  • Add image-reward to your pyproject.toml so that the ImageReward model can be imported.

📐 Metric Class

For the full deep-dive on Pruna metrics (class structure, state handling, tests, registration), check out our guide:
Customize a Metric

Quick Overview

  1. File & Class

    • Create pruna/evaluation/metrics/metric_image_reward.py
    • Inherit from StatefulMetric
  2. Configuration

    • Choose a sensible call_type and set metric_name = "image_reward"
    • Define and register any internal state via self.add_state(...)
  3. Implement Core Methods

    • update(x, gt, outputs)
      • Receive inputs, ground truths, and model outputs
      • Feed the generated images into the ImageReward model to compute per-image scores
      • Accumulate scores in your state variables
    • compute()
      • Aggregate your state (e.g., average all scores)
      • Return a result with name "image_reward" and the aggregated float
  4. Registration

    • Use the @MetricRegistry.register("image_reward") decorator so users can invoke your metric by name
  5. Testing & Docs

    • Write unit tests under tests/evaluation/metrics/test_image_reward.py
    • Update user_manual/evaluation.rst to mention "image_reward"

✅ Acceptance Criteria

  • Single Load: The ImageReward model is loaded once in the metric’s constructor.
  • Correct Output: compute(...) returns a sensible result (e.g. if available a public benchmark score!)
  • Tests & Docs: All existing and new unit tests pass, and the documentation is updated!

❓ Questions?

Feel free to jump into our Discord channel if you hit any roadblocks, can’t wait to see your contribution! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions