✨ 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
-
File & Class
- Create
pruna/evaluation/metrics/metric_image_reward.py
- Inherit from
StatefulMetric
-
Configuration
- Choose a sensible
call_type and set metric_name = "image_reward"
- Define and register any internal state via
self.add_state(...)
-
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
-
Registration
- Use the
@MetricRegistry.register("image_reward") decorator so users can invoke your metric by name
-
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! 🎉
✨ 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
image-rewardto yourpyproject.tomlso 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
File & Class
pruna/evaluation/metrics/metric_image_reward.pyStatefulMetricConfiguration
call_typeand setmetric_name = "image_reward"self.add_state(...)Implement Core Methods
update(x, gt, outputs)compute()"image_reward"and the aggregated floatRegistration
@MetricRegistry.register("image_reward")decorator so users can invoke your metric by nameTesting & Docs
tests/evaluation/metrics/test_image_reward.pyuser_manual/evaluation.rstto mention"image_reward"✅ Acceptance Criteria
compute(...)returns a sensible result (e.g. if available a public benchmark score!)❓ Questions?
Feel free to jump into our Discord channel if you hit any roadblocks, can’t wait to see your contribution! 🎉