import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
from EditReward import EditRewardInferencer
CHECKPOINT_PATH = "your/local/path/to/checkpoint"
CONFIG_PATH = "config/EditReward-MiMo-VL-7B-SFT-2508.yaml"
inferencer = EditRewardInferencer(
config_path=CONFIG_PATH,
checkpoint_path=CHECKPOINT_PATH,
device="cuda",
reward_dim="overall_detail",
rm_head_type="ranknet_multi_head"
)
image_src = [
"your/local/path/to/source_image_1.jpg",
"your/local/path/to/source_image_2.jpg",
]
image_paths = [
"your/local/path/to/edited_image_1.jpg",
"your/local/path/to/edited_image_2.jpg",
]
prompts = [
"your first editing instruction",
"your second editing instruction"
]
if __name__ == "__main__":
mode = "pairwise_inference"
if mode == "pairwise_inference":
with torch.no_grad():
rewards = inferencer.reward(
prompts=prompts,
image_src=image_src,
image_paths=image_paths
)
scores = [reward[0].item() for reward in rewards]
print(f"[Pairwise Inference] Image scores: {scores}")
elif mode == "single_inference":
with torch.no_grad():
rewards = inferencer.reward(
prompts=[prompts[0]],
image_src=[image_src[0]],
image_paths=[image_paths[0]]
)
print(f"[Single Inference] Image 1 score: {[reward[0].item() for reward in rewards]}")
with torch.no_grad():
rewards = inferencer.reward(
prompts=[prompts[0]],
image_src=[image_src[0]],
image_paths=[image_paths[1]]
)
print(f"[Single Inference] Image 2 score: {[reward[0].item() for reward in rewards]}")