latentblending/example1_standard.py

42 lines
1.5 KiB
Python
Raw Normal View History

2023-11-16 14:37:02 +00:00
# Copyright 2022 Lunar Ring. All rights reserved.
# Written by Johannes Stelzer, email stelzer@lunar-ring.ai twitter @j_stelzer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import torch
import warnings
from latent_blending import LatentBlending
from diffusers_holder import DiffusersHolder
2024-01-06 17:16:36 +00:00
from diffusers import AutoPipelineForText2Image
2024-01-09 14:58:56 +00:00
2023-11-16 14:37:02 +00:00
warnings.filterwarnings('ignore')
torch.set_grad_enabled(False)
torch.backends.cudnn.benchmark = False
# %% First let us spawn a stable diffusion holder. Uncomment your version of choice.
2024-01-06 17:16:36 +00:00
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
pipe.to("cuda")
2023-11-16 14:37:02 +00:00
dh = DiffusersHolder(pipe)
lb = LatentBlending(dh)
2024-01-09 14:55:42 +00:00
lb.set_prompt1("photo of underwater landscape, fish, und the sea, incredible detail, high resolution")
lb.set_prompt2("rendering of an alien planet, strange plants, strange creatures, surreal")
lb.set_negative_prompt("blurry, ugly, pale")
2023-11-16 14:37:02 +00:00
# Run latent blending
2024-01-09 14:55:42 +00:00
lb.run_transition()
2023-11-16 14:37:02 +00:00
# Save movie
2024-01-09 14:55:42 +00:00
lb.write_movie_transition('movie_example1.mp4', duration_transition=12)