From 8049b42091390277b5996fddf168fb199ea2b851 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 23 Jul 2024 00:23:43 +0200 Subject: [PATCH] added stuff to diffusers --- lollms/services/diffusers/lollms_diffusers.py | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lollms/services/diffusers/lollms_diffusers.py b/lollms/services/diffusers/lollms_diffusers.py index 99a1009..fd05a0d 100644 --- a/lollms/services/diffusers/lollms_diffusers.py +++ b/lollms/services/diffusers/lollms_diffusers.py @@ -19,6 +19,16 @@ from lollms.utilities import git_pull from tqdm import tqdm import threading +import pipmaster as pm +if not pm.is_installed("torch"): + pm.install_or_update("torch torchvision torchaudio", "https://download.pytorch.org/whl/cu121") + +import torch +if not torch.cuda.is_available(): + pm.install_or_update("torch torchvision torchaudio", "https://download.pytorch.org/whl/cu121") + + + def adjust_dimensions(value: int) -> int: """Adjusts the given value to be divisible by 8.""" return (value // 8) * 8 @@ -152,10 +162,13 @@ class LollmsDiffusers(LollmsTTI): # use_safetensors=True, # ) # app.config.diffusers_model # Enable memory optimizations. - if app.config.diffusers_offloading_mode=="sequential_cpu_offload": - self.model.enable_sequential_cpu_offload() - elif app.coinfig.diffusers_offloading_mode=="model_cpu_offload": - self.model.enable_model_cpu_offload() + try: + if app.config.diffusers_offloading_mode=="sequential_cpu_offload": + self.model.enable_sequential_cpu_offload() + elif app.coinfig.diffusers_offloading_mode=="model_cpu_offload": + self.model.enable_model_cpu_offload() + except: + pass except Exception as ex: self.model= None trace_exception(ex) @@ -221,8 +234,8 @@ class LollmsDiffusers(LollmsTTI): sc = self.get_scheduler_by_name(sampler_name) if sc: self.model.scheduler = sc - width = adjust_dimensions(width) - height = adjust_dimensions(height) + width = adjust_dimensions(int(width)) + height = adjust_dimensions(int(height)) if output_path is None: output_path = self.output_dir if seed!=-1: