🚀 InstructCV:指令調優的文本到圖像擴散模型,成為視覺多面手
InstructCV 是一種經過指令調優的文本到圖像擴散模型,可作為視覺通用模型,在圖像到圖像等任務中表現出色,利用相關數據集進行訓練,具有廣泛的應用前景。
🚀 快速開始
要使用 InstructCV
,目前需要使用 main
版本安裝 diffusers
。該管道將在下一版本中正式可用。
📦 安裝指南
pip install diffusers accelerate safetensors transformers
💻 使用示例
基礎用法
import PIL
import requests
import torch
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
model_id = "yulu2/InstructCV"
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None, variant="ema")
pipe.to("cuda")
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
url = "put your url here"
def download_image(url):
image = PIL.Image.open(requests.get(url, stream=True).raw)
image = PIL.ImageOps.exif_transpose(image)
image = image.convert("RGB")
return image
image = download_image(URL)
seed = random.randint(0, 100000)
generator = torch.manual_seed(seed)
width, height = image.size
factor = 512 / max(width, height)
factor = math.ceil(min(width, height) * factor / 64) * 64 / min(width, height)
width = int((width * factor) // 64) * 64
height = int((height * factor) // 64) * 64
image = ImageOps.fit(image, (width, height), method=Image.Resampling.LANCZOS)
prompt = "Detect the person."
images = pipe(prompt, image=image, num_inference_steps=100, generator=generator).images[0]
images[0]
📄 許可證
本項目採用 MIT 許可證。
相關鏈接
- GitHub: https://github.com/AlaaLab/InstructCV
- 項目圖片
數據集
本項目使用了 yulu2/InstructCV-Demo-Data
數據集。
屬性 |
詳情 |
模型類型 |
指令調優的文本到圖像擴散模型 |
訓練數據 |
yulu2/InstructCV-Demo-Data |