Browse Source

Disable: forward chunking

Inpaint_experimental
tin2tin 1 year ago committed by GitHub
parent
commit
6cf3807c31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      __init__.py

18
__init__.py

@ -1090,9 +1090,10 @@ class SEQUENCER_OT_generate_movie(Operator):
# Models for refine imported image or movie # Models for refine imported image or movie
if (scene.movie_path or scene.image_path) and input == "input_strips": if (scene.movie_path or scene.image_path) and input == "input_strips":
#img2img
if movie_model_card == "stabilityai/stable-diffusion-xl-base-1.0": if movie_model_card == "stabilityai/stable-diffusion-xl-base-1.0": #img2img
from diffusers import StableDiffusionXLImg2ImgPipeline from diffusers import StableDiffusionXLImg2ImgPipeline
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained( pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
movie_model_card, movie_model_card,
torch_dtype=torch.float16, torch_dtype=torch.float16,
@ -1113,6 +1114,7 @@ class SEQUENCER_OT_generate_movie(Operator):
pipe.to("cuda") pipe.to("cuda")
from diffusers import StableDiffusionXLImg2ImgPipeline from diffusers import StableDiffusionXLImg2ImgPipeline
refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained( refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-refiner-1.0", "stabilityai/stable-diffusion-xl-refiner-1.0",
text_encoder_2=pipe.text_encoder_2, text_encoder_2=pipe.text_encoder_2,
@ -1130,23 +1132,27 @@ class SEQUENCER_OT_generate_movie(Operator):
else: else:
if movie_model_card == "cerspense/zeroscope_v2_dark_30x448x256" or movie_model_card == "cerspense/zeroscope_v2_576w" or scene.image_path: if movie_model_card == "cerspense/zeroscope_v2_dark_30x448x256" or movie_model_card == "cerspense/zeroscope_v2_576w" or scene.image_path:
card = "cerspense/zeroscope_v2_XL" card = "cerspense/zeroscope_v2_XL"
safe = False
else: else:
card = movie_model_card card = movie_model_card
safe = True
from diffusers import VideoToVideoSDPipeline from diffusers import VideoToVideoSDPipeline
upscale = VideoToVideoSDPipeline.from_pretrained( upscale = VideoToVideoSDPipeline.from_pretrained(
card, card,
torch_dtype=torch.float16, torch_dtype=torch.float16,
use_safetensors=safe,
) )
from diffusers import DPMSolverMultistepScheduler from diffusers import DPMSolverMultistepScheduler
upscale.scheduler = DPMSolverMultistepScheduler.from_config(upscale.scheduler.config) upscale.scheduler = DPMSolverMultistepScheduler.from_config(upscale.scheduler.config)
if low_vram: if low_vram:
torch.cuda.set_per_process_memory_fraction(0.98) torch.cuda.set_per_process_memory_fraction(0.98)
upscale.enable_model_cpu_offload() upscale.enable_model_cpu_offload()
upscale.unet.enable_forward_chunking(chunk_size=1, dim=1) # here: #upscale.unet.enable_forward_chunking(chunk_size=1, dim=1) # here:
upscale.enable_vae_slicing() upscale.enable_vae_slicing()
else: else:
upscale.to("cuda") upscale.to("cuda")
@ -1157,6 +1163,7 @@ class SEQUENCER_OT_generate_movie(Operator):
pipe = TextToVideoSDPipeline.from_pretrained( pipe = TextToVideoSDPipeline.from_pretrained(
movie_model_card, movie_model_card,
torch_dtype=torch.float16, torch_dtype=torch.float16,
use_safetensors=False,
) )
from diffusers import DPMSolverMultistepScheduler from diffusers import DPMSolverMultistepScheduler
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config) pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
@ -1174,14 +1181,15 @@ class SEQUENCER_OT_generate_movie(Operator):
from diffusers import DiffusionPipeline from diffusers import DiffusionPipeline
upscale = DiffusionPipeline.from_pretrained( upscale = DiffusionPipeline.from_pretrained(
"cerspense/zeroscope_v2_XL", torch_dtype=torch.float16 "cerspense/zeroscope_v2_XL", torch_dtype=torch.float16,
use_safetensors=False,
) )
upscale.scheduler = DPMSolverMultistepScheduler.from_config(upscale.scheduler.config) upscale.scheduler = DPMSolverMultistepScheduler.from_config(upscale.scheduler.config)
if low_vram: if low_vram:
upscale.enable_model_cpu_offload() upscale.enable_model_cpu_offload()
upscale.unet.enable_forward_chunking(chunk_size=1, dim=1) #Heavy #upscale.unet.enable_forward_chunking(chunk_size=1, dim=1) #Heavy
upscale.enable_vae_slicing() upscale.enable_vae_slicing()
else: else:
upscale.to("cuda") upscale.to("cuda")

Loading…
Cancel
Save