Buckets:
twanghcmut/backup-foundation-physics / third_party /diffsynth /examples /image_quality_metric /lpips.py
| from diffsynth.metrics import LPIPSMetric, ModelConfig | |
| from modelscope import dataset_snapshot_download | |
| dataset_snapshot_download( | |
| "DiffSynth-Studio/diffsynth_example_dataset", | |
| allow_file_pattern=["flux/FLUX.1-dev/*", "flux2/FLUX.2-dev/*"], | |
| local_dir="./data/diffsynth_example_dataset", | |
| ) | |
| # net="alex" with LPIPS/alexnet.safetensors (default) | |
| # For VGG: net="vgg", model_config=ModelConfig(model_id="DiffSynth-Studio/ImageMetrics", origin_file_pattern="LPIPS/vgg.safetensors") | |
| # For SqueezeNet: net="squeeze", model_config=ModelConfig(model_id="DiffSynth-Studio/ImageMetrics", origin_file_pattern="LPIPS/squeezenet.safetensors") | |
| metric = LPIPSMetric.from_pretrained( | |
| net="alex", | |
| model_config=ModelConfig( | |
| model_id="DiffSynth-Studio/ImageMetrics", | |
| origin_file_pattern="LPIPS/alexnet.safetensors", | |
| ), | |
| device="cuda", | |
| target_size=512, | |
| ) | |
| score = metric.compute( | |
| "./data/diffsynth_example_dataset/flux/FLUX.1-dev/1.jpg", | |
| "./data/diffsynth_example_dataset/flux/FLUX.1-dev/2.jpg", | |
| ) | |
| print(f"LPIPS score (image vs image): {score:.4f}") | |
| score = metric.compute( | |
| "./data/diffsynth_example_dataset/flux/FLUX.1-dev", | |
| "./data/diffsynth_example_dataset/flux2/FLUX.2-dev", | |
| ) | |
| print(f"LPIPS score (dir vs dir): {score:.4f}") | |
Xet Storage Details
- Size:
- 1.27 kB
- Xet hash:
- 510846b3a4dd9e225ac0a1a8b7174a8dbd5e14c2587b5ea6dc701993ac0c3d14
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.