MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / __init__

Method __init__

diffsynth/extensions/ImageQualityMetric/mps.py:28–43  ·  view source on GitHub ↗
(self, device: Union[str, torch.device], path: str = MODEL_PATHS, condition: str = 'overall')

Source from the content-addressed store, hash-verified

26
27class MPScore(torch.nn.Module):
28 def __init__(self, device: Union[str, torch.device], path: str = MODEL_PATHS, condition: str = 'overall'):
29 super().__init__()
30 """Initialize the MPSModel with a processor, tokenizer, and model.
31
32 Args:
33 device (Union[str, torch.device]): The device to load the model on.
34 """
35 self.device = device
36 processor_name_or_path = path.get("clip")
37 self.image_processor = CLIPImageProcessor.from_pretrained(processor_name_or_path)
38 self.tokenizer = AutoTokenizer.from_pretrained(processor_name_or_path, trust_remote_code=True)
39 self.model = clip_model.CLIPModel(processor_name_or_path, config_file=True)
40 state_dict = load_file(path.get("mps"))
41 self.model.load_state_dict(state_dict, strict=False)
42 self.model.to(device)
43 self.condition = condition
44
45 def _calculate_score(self, image: torch.Tensor, prompt: str) -> float:
46 """Calculate the reward score for a single image and prompt.

Callers

nothing calls this directly

Calls 2

from_pretrainedMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected