Download examples/image_quality_metric/pickscore.py from ymyy307/diffsynth: direct link, hf CLI and curl.
- Browser
- Download file 676 Bytes
-
https://huggingface.co/ymyy307/diffsynth/resolve/main/examples/image_quality_metric/pickscore.py
- Command line
-
hf download hf://ymyy307/diffsynth/examples/image_quality_metric/pickscore.py
-
curl -L -o pickscore.py https://huggingface.co/ymyy307/diffsynth/resolve/main/examples/image_quality_metric/pickscore.py
676 Bytes
| from diffsynth.metrics import PickScoreMetric, ModelConfig | |
| from modelscope import dataset_snapshot_download | |
| from PIL import Image | |
| dataset_snapshot_download( | |
| "DiffSynth-Studio/diffsynth_example_dataset", | |
| allow_file_pattern="flux/FLUX.1-dev/*", | |
| local_dir="./data/diffsynth_example_dataset", | |
| ) | |
| image = Image.open("data/diffsynth_example_dataset/flux/FLUX.1-dev/1.jpg").convert("RGB") | |
| prompt = "a dog" | |
| metric = PickScoreMetric.from_pretrained( | |
| model_config=ModelConfig(model_id="DiffSynth-Studio/ImageMetrics", origin_file_pattern="PickScore/model.safetensors"), | |
| device="cuda" | |
| ) | |
| score = metric.compute(prompt, image)[0] | |
| print(f"PickScore score:: {score:.3f}") |