🚀 InstructCLIP: 対照学習を用いた自動データ改良による指示型画像編集の改善 (CVPR 2025)
このモデルは、PytorchModelHubMixin を使ってハブにアップロードされています。このモデルは論文 Instruct-CLIP: Improving Instruction-Guided Image Editing with Automated Data Refinement Using Contrastive Learning に基づいています。
Arxiv | 画像編集モデル | データ改良モデル | データ
🚀 クイックスタート
このモデルは、対照学習を用いた自動データ改良により、指示型画像編集を改善するものです。以下のセクションでは、インストール方法と使用例を紹介します。
✨ 主な機能
- 指示型画像編集の精度向上
- 自動データ改良による学習効率の向上
📦 インストール
pip install -r requirements.txt
💻 使用例
基本的な使用法
from PIL import Image
import torch
from torchvision import transforms
from model import InstructCLIP
from utils import get_sd_components, normalize
parser = argparse.ArgumentParser(description="Simple example of estimating edit instruction from image pair")
parser.add_argument(
"--pretrained_instructclip_name_or_path",
type=str,
default="SherryXTChen/Instruct-CLIP",
help=(
"instructclip pretrained checkpoints"
),
)
parser.add_argument(
"--pretrained_model_name_or_path",
type=str,
default="runwayml/stable-diffusion-v1-5",
help=(
"sd pretrained checkpoints"
),
)
parser.add_argument(
"--input_path",
type=str,
default="assets/1_input.jpg",
help=(
"Input image path"
)
)
parser.add_argument(
"--output_path",
type=str,
default="assets/1_output.jpg",
help=(
"Output image path"
)
)
args = parser.parse_args()
device = "cuda"
model = InstructCLIP.from_pretrained("SherryXTChen/Instruct-CLIP")
model = model.to(device).eval()
tokenizer, _, vae, _, _ = get_sd_components(args, device, torch.float32)
transform = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize(mean=[0.5], std=[0.5]),
])
image_list = [args.input_path, args.output_path]
image_list = [
transform(Image.open(f).resize((512, 512))).unsqueeze(0).to(device)
for f in image_list
]
with torch.no_grad():
image_list = [vae.encode(x).latent_dist.sample() * vae.config.scaling_factor for x in image_list]
zero_timesteps = torch.zeros_like(torch.tensor([0])).to(device)
img_feat = model.get_image_features(
inp=image_list[0], out=image_list[1], inp_t=zero_timesteps, out_t=zero_timesteps)
img_feat = normalize(img_feat)
pred_instruct_input_ids = model.text_decoder.infer(img_feat[:1])[0]
pred_instruct = tokenizer.decode(pred_instruct_input_ids, skip_special_tokens=True)
print(pred_instruct)
📚 ドキュメント
モデル情報
属性 |
詳情 |
ベースモデル |
SherryXTChen/LatentDiffusionDINOv2 |
データセット |
timbrooks/instructpix2pix-clip-filtered, SherryXTChen/InstructCLIP-InstructPix2Pix-Data |
言語 |
en |
パイプラインタグ |
image-to-image |
ライブラリ名 |
diffusers |
タグ |
model_hub_mixin, pytorch_model_hub_mixin |
引用
@misc{chen2025instructclipimprovinginstructionguidedimage,
title={Instruct-CLIP: Improving Instruction-Guided Image Editing with Automated Data Refinement Using Contrastive Learning},
author={Sherry X. Chen and Misha Sra and Pradeep Sen},
year={2025},
eprint={2503.18406},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2503.18406},
}
📄 ライセンス
このモデルは、Apache License 2.0の下で提供されています。