mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-25 10:48:11 +00:00
rearrange examples
This commit is contained in:
31
examples/image_synthesis/sdxl_turbo.py
Normal file
31
examples/image_synthesis/sdxl_turbo.py
Normal 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")
|
||||
Reference in New Issue
Block a user