rearrange examples

This commit is contained in:
Artiprocher
2024-06-06 18:50:07 +08:00
parent f6de5eef4d
commit 4d4a095420
20 changed files with 140 additions and 45 deletions

View File

@@ -0,0 +1,31 @@
from diffsynth import ModelManager, SDXLImagePipeline
import torch
# Download models
# `models/stable_diffusion_xl_turbo/sd_xl_turbo_1.0_fp16.safetensors`: [link](https://huggingface.co/stabilityai/sdxl-turbo/resolve/main/sd_xl_turbo_1.0_fp16.safetensors)
# Load models
model_manager = ModelManager(torch_dtype=torch.float16, device="cuda")
model_manager.load_models(["models/stable_diffusion_xl_turbo/sd_xl_turbo_1.0_fp16.safetensors"])
pipe = SDXLImagePipeline.from_model_manager(model_manager)
# Text to image
torch.manual_seed(0)
image = pipe(
prompt="black car",
# Do not modify the following parameters!
cfg_scale=1, height=512, width=512, num_inference_steps=1, progress_bar_cmd=lambda x:x
)
image.save(f"black_car.jpg")
# Image to image
torch.manual_seed(0)
image = pipe(
prompt="red car",
input_image=image, denoising_strength=0.7,
# Do not modify the following parameters!
cfg_scale=1, height=512, width=512, num_inference_steps=1, progress_bar_cmd=lambda x:x
)
image.save(f"black_car_to_red_car.jpg")